diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php index 12747e6dc2..30bfc56a11 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php @@ -105,7 +105,8 @@ class AppKernel extends Kernel public function unserialize($str) { - call_user_func_array(array($this, '__construct'), unserialize($str)); + $a = unserialize($str); + $this->__construct($a[0], $a[1], $a[2], $a[3]); } protected function getKernelParameters() diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php index 57816ccef9..dfce6e4a6c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php @@ -105,7 +105,8 @@ class AppKernel extends Kernel public function unserialize($str) { - call_user_func_array(array($this, '__construct'), unserialize($str)); + $a = unserialize($str); + $this->__construct($a[0], $a[1], $a[2], $a[3]); } protected function getKernelParameters() diff --git a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php index 7cbddc6cf3..885863bbb6 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php @@ -225,8 +225,10 @@ class ExprBuilder { foreach ($expressions as $k => $expr) { if ($expr instanceof ExprBuilder) { - $expressions[$k] = function ($v) use ($expr) { - return call_user_func($expr->ifPart, $v) ? call_user_func($expr->thenPart, $v) : $v; + $if = $expr->ifPart; + $then = $expr->thenPart; + $expressions[$k] = function ($v) use ($if, $then) { + return $if($v) ? $then($v) : $v; }; } } diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index 6d89e49df5..a19dd58bf8 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -49,7 +49,9 @@ class VariableNode extends BaseNode implements PrototypeNodeInterface */ public function getDefaultValue() { - return $this->defaultValue instanceof \Closure ? call_user_func($this->defaultValue) : $this->defaultValue; + $v = $this->defaultValue; + + return $v instanceof \Closure ? $v() : $v; } /** diff --git a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php index b1ad4420dc..6a3b01cfbe 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php @@ -22,6 +22,6 @@ class FileLoaderImportCircularReferenceException extends FileLoaderLoadException { $message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]); - call_user_func('Exception::__construct', $message, $code, $previous); + \Exception::__construct($message, $code, $previous); } } diff --git a/src/Symfony/Component/Finder/Shell/Command.php b/src/Symfony/Component/Finder/Shell/Command.php index de701ab4e8..7fcb303004 100644 --- a/src/Symfony/Component/Finder/Shell/Command.php +++ b/src/Symfony/Component/Finder/Shell/Command.php @@ -248,14 +248,14 @@ class Command */ public function execute() { - if (null === $this->errorHandler) { + if (null === $errorHandler = $this->errorHandler) { exec($this->join(), $output); } else { $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY); if ($error = stream_get_contents($pipes[2])) { - call_user_func($this->errorHandler, $error); + $errorHandler($error); } proc_close($process); diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php index cf23d7bf8a..f84d67a0c7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php @@ -74,8 +74,8 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface $response = new Response($this->body, $this->status, $this->headers); - if (null !== $this->customizer) { - call_user_func($this->customizer, $request, $response); + if (null !== $customizer = $this->customizer) { + $customizer($request, $response); } return $response; diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 908a126ffa..e163ab8665 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1102,11 +1102,12 @@ class Process $result = $this->processPipes->read($blocking); } + $callback = $this->callback; foreach ($result as $type => $data) { if (3 == $type) { $this->fallbackExitcode = (int) $data; } else { - call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data); + $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); } } } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 5689d34067..2a9e9033d1 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -747,7 +747,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase { $process = $this->getProcess('php -m'); $this->setExpectedException('Symfony\Component\Process\Exception\LogicException', sprintf('Process must be started before calling %s.', $method)); - call_user_func(array($process, $method)); + $process->{$method}(); } public function provideMethodsThatNeedARunningProcess() @@ -769,7 +769,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $process = $this->getProcess('php -r "sleep(1);"'); $process->start(); try { - call_user_func(array($process, $method)); + $process->{$method}(); $process->stop(0); $this->fail('A LogicException must have been thrown'); } catch (\Exception $e) { diff --git a/src/Symfony/Component/Routing/Loader/ClosureLoader.php b/src/Symfony/Component/Routing/Loader/ClosureLoader.php index 8212c2916d..9edab1e9e3 100644 --- a/src/Symfony/Component/Routing/Loader/ClosureLoader.php +++ b/src/Symfony/Component/Routing/Loader/ClosureLoader.php @@ -37,7 +37,7 @@ class ClosureLoader extends Loader */ public function load($closure, $type = null) { - return call_user_func($closure); + return $closure(); } /** diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index ca5a42bca0..32b20e8a50 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -43,7 +43,9 @@ class CallbackValidator extends ConstraintValidator $methods = $constraint->methods; foreach ($methods as $method) { - if (is_array($method) || $method instanceof \Closure) { + if ($method instanceof \Closure) { + $method($object, $this->context); + } elseif (is_array($method)) { if (!is_callable($method)) { throw new ConstraintDefinitionException(sprintf('"%s::%s" targeted by Callback constraint is not a valid callable', $method[0], $method[1])); } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 93f13c75da..0581d7da74 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -45,13 +45,12 @@ class ChoiceValidator extends ConstraintValidator } if ($constraint->callback) { - if (is_callable(array($this->context->getClassName(), $constraint->callback))) { - $choices = call_user_func(array($this->context->getClassName(), $constraint->callback)); - } elseif (is_callable($constraint->callback)) { - $choices = call_user_func($constraint->callback); - } else { + if (!is_callable($choices = array($this->context->getClassName(), $constraint->callback)) + && !is_callable($choices = $constraint->callback) + ) { throw new ConstraintDefinitionException('The Choice constraint expects a valid callback'); } + $choices = call_user_func($choices); } else { $choices = $constraint->choices; } diff --git a/src/Symfony/Component/Validator/Constraints/TypeValidator.php b/src/Symfony/Component/Validator/Constraints/TypeValidator.php index b89b5cba1d..979df4ec67 100644 --- a/src/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -35,9 +35,9 @@ class TypeValidator extends ConstraintValidator $isFunction = 'is_'.$type; $ctypeFunction = 'ctype_'.$type; - if (function_exists($isFunction) && call_user_func($isFunction, $value)) { + if (function_exists($isFunction) && $isFunction($value)) { return; - } elseif (function_exists($ctypeFunction) && call_user_func($ctypeFunction, $value)) { + } elseif (function_exists($ctypeFunction) && $ctypeFunction($value)) { return; } elseif ($value instanceof $constraint->type) { return;