Skip to content

Commit

Permalink
Merge pull request #3252 from morozov/call-user-func-array-to-variadic
Browse files Browse the repository at this point in the history
Replaced call_user_func_array() of a fixed method with the usage of variadic arguments
  • Loading branch information
Ocramius authored Aug 16, 2018
2 parents 66daecd + 35093a4 commit 437ad0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use const DB2_LONG;
use const DB2_PARAM_IN;
use function array_change_key_case;
use function call_user_func_array;
use function db2_bind_param;
use function db2_execute;
use function db2_fetch_array;
Expand Down
8 changes: 3 additions & 5 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Doctrine\DBAL\ParameterType;
use function array_combine;
use function array_fill;
use function call_user_func_array;
use function count;
use function str_repeat;

Expand Down Expand Up @@ -172,7 +171,7 @@ public function execute($params = null)
throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
}
} else {
if (!call_user_func_array([$this->_stmt, 'bind_param'], [$this->types] + $this->_bindedValues)) {
if (! $this->_stmt->bind_param($this->types, ...$this->_bindedValues)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
}
Expand Down Expand Up @@ -221,7 +220,7 @@ public function execute($params = null)
$refs[$key] =& $value;
}

if (!call_user_func_array([$this->_stmt, 'bind_result'], $refs)) {
if (! $this->_stmt->bind_result(...$refs)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
}
Expand All @@ -242,13 +241,12 @@ private function _bindValues($values)
{
$params = [];
$types = str_repeat('s', count($values));
$params[0] = $types;

foreach ($values as &$v) {
$params[] =& $v;
}

return call_user_func_array([$this->_stmt, 'bind_param'], $params);
return $this->_stmt->bind_param($types, ...$params);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use IteratorAggregate;
use const SASQL_BOTH;
use function array_key_exists;
use function call_user_func_array;
use function func_get_args;
use function func_num_args;
use function gettype;
Expand Down Expand Up @@ -280,7 +279,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n

switch ($fetchMode) {
case FetchMode::CUSTOM_OBJECT:
while ($row = call_user_func_array([$this, 'fetch'], func_get_args())) {
while ($row = $this->fetch(...func_get_args())) {
$rows[] = $row;
}
break;
Expand Down

0 comments on commit 437ad0d

Please sign in to comment.