diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index bb37d99b21..6100eb87a5 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -149,7 +149,7 @@ EOF return; } $refl = new \ReflectionMethod($cb[0], $cb[1]); - } elseif (is_object($cb) && is_callable($cb)) { + } elseif (is_object($cb) && method_exists($cb, '__invoke')) { $refl = new \ReflectionMethod($cb, '__invoke'); } elseif (function_exists($cb)) { $refl = new \ReflectionFunction($cb); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml index 4078a656d5..3ef3ec90d0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml @@ -12,7 +12,7 @@ - + null null null diff --git a/src/Symfony/Component/Console/Helper/ProcessHelper.php b/src/Symfony/Component/Console/Helper/ProcessHelper.php index fab23ee0d4..2c46a2c39d 100644 --- a/src/Symfony/Component/Console/Helper/ProcessHelper.php +++ b/src/Symfony/Component/Console/Helper/ProcessHelper.php @@ -36,7 +36,7 @@ class ProcessHelper extends Helper * * @return Process The process that ran */ - public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) + public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); @@ -92,7 +92,7 @@ class ProcessHelper extends Helper * * @see run() */ - public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null) + public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null) { $process = $this->run($output, $cmd, $error, $callback); @@ -112,7 +112,7 @@ class ProcessHelper extends Helper * * @return callable */ - public function wrapCallback(OutputInterface $output, Process $process, $callback = null) + public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null) { if ($output instanceof ConsoleOutputInterface) { $output = $output->getErrorOutput(); diff --git a/src/Symfony/Component/Console/Helper/ProgressBar.php b/src/Symfony/Component/Console/Helper/ProgressBar.php index 099f45420a..59127f943a 100644 --- a/src/Symfony/Component/Console/Helper/ProgressBar.php +++ b/src/Symfony/Component/Console/Helper/ProgressBar.php @@ -86,7 +86,7 @@ class ProgressBar * @param string $name The placeholder name (including the delimiter char like %) * @param callable $callable A PHP callable */ - public static function setPlaceholderFormatterDefinition($name, $callable) + public static function setPlaceholderFormatterDefinition($name, callable $callable) { if (!self::$formatters) { self::$formatters = self::initPlaceholderFormatters(); diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index b95bf9e5f5..13ea0d0834 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -377,7 +377,7 @@ class QuestionHelper extends Helper * * @throws \Exception In case the max number of attempts has been reached and no valid response has been given */ - private function validateAttempts($interviewer, OutputInterface $output, Question $question) + private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) { $error = null; $attempts = $question->getMaxAttempts(); diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 9aa4c69d27..71cb8f5c8b 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -164,7 +164,7 @@ class Question * * @return Question The current instance */ - public function setValidator($validator) + public function setValidator(callable $validator = null) { $this->validator = $validator; @@ -220,11 +220,11 @@ class Question * * The normalizer can be a callable (a string), a closure or a class implementing __invoke. * - * @param string|\Closure $normalizer + * @param callable $normalizer * * @return Question The current instance */ - public function setNormalizer($normalizer) + public function setNormalizer(callable $normalizer) { $this->normalizer = $normalizer; @@ -236,7 +236,7 @@ class Question * * The normalizer can ba a callable (a string), a closure or a class implementing __invoke. * - * @return string|\Closure + * @return callable */ public function getNormalizer() { diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php b/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php index 7222261cd5..c42f29f609 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php +++ b/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php @@ -41,7 +41,7 @@ class ExpressionFunction * @param callable $compiler A callable able to compile the function * @param callable $evaluator A callable able to evaluate the function */ - public function __construct($name, $compiler, $evaluator) + public function __construct($name, callable $compiler, callable $evaluator) { $this->name = $name; $this->compiler = $compiler; diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php b/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php index fb3faf79a5..e40afd00ed 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php +++ b/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php @@ -112,7 +112,7 @@ class ExpressionLanguage * * @see ExpressionFunction */ - public function register($name, $compiler, $evaluator) + public function register($name, callable $compiler, callable $evaluator) { $this->functions[$name] = array('compiler' => $compiler, 'evaluator' => $evaluator); } diff --git a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php index 24b15d97ad..b43b88d98d 100644 --- a/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php @@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator /** * Constructor. * - * @param \Iterator $iterator The Iterator to filter - * @param array $filters An array of PHP callbacks + * @param \Iterator $iterator The Iterator to filter + * @param callable[] $filters An array of PHP callbacks * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php index 7c3c107d0f..55cfab399f 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php @@ -101,7 +101,7 @@ class ArrayKeyChoiceList extends ArrayChoiceList * the keys of the values or if any of the * choices is not scalar */ - public function __construct($choices, $value = null) + public function __construct($choices, callable $value = null) { // If no values are given, use the choices as values // Since the choices are stored in the collection keys, i.e. they are diff --git a/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php b/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php index f691d71330..27d8deb882 100644 --- a/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/LazyChoiceList.php @@ -59,7 +59,7 @@ class LazyChoiceList implements ChoiceListInterface * @param null|callable $value The callable generating the choice * values */ - public function __construct(ChoiceLoaderInterface $loader, $value = null) + public function __construct(ChoiceLoaderInterface $loader, callable $value = null) { $this->loader = $loader; $this->value = $value; diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 90c272b469..b021d3c405 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -36,7 +36,7 @@ class StreamedResponse extends Response * @param int $status The response status code * @param array $headers An array of response headers */ - public function __construct($callback = null, $status = 200, $headers = array()) + public function __construct(callable $callback = null, $status = 200, $headers = array()) { parent::__construct(null, $status, $headers); diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 1af46dc656..a4a5fdba14 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -131,7 +131,7 @@ class ControllerResolver implements ControllerResolverInterface * * @param string $controller A Controller string * - * @return mixed A PHP callable + * @return callable A PHP callable * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php index 93c9553fd4..e0af13106c 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php @@ -29,12 +29,10 @@ class FilterControllerEvent extends KernelEvent { /** * The current controller. - * - * @var callable */ private $controller; - public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType) + public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, $requestType) { parent::__construct($kernel, $request, $requestType); diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index f50e4d6c3b..33a543819d 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -45,7 +45,7 @@ class DebugHandlersListener implements EventSubscriberInterface * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged * @param string $fileLinkFormat The format for links to source files */ - public function __construct($exceptionHandler, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null) + public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null) { $this->exceptionHandler = $exceptionHandler; $this->logger = $logger; diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php index 97e68f66f9..06f611ef46 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php @@ -154,17 +154,6 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase $kernel->handle(new Request()); } - /** - * @expectedException \LogicException - */ - public function testHandleWhenTheControllerIsNotACallable() - { - $dispatcher = new EventDispatcher(); - $kernel = new HttpKernel($dispatcher, $this->getResolver('foobar')); - - $kernel->handle(new Request()); - } - public function testHandleWhenTheControllerIsAClosure() { $response = new Response('foo'); diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index e5777ea22a..583516bbbe 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -54,7 +54,7 @@ class PhpProcess extends Process /** * {@inheritdoc} */ - public function start($callback = null) + public function start(callable $callback = null) { if (null === $this->getCommandLine()) { throw new RuntimeException('Unable to find the PHP executable.'); diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 02499cb208..3a369fd3bf 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -217,7 +217,7 @@ class Process * @throws RuntimeException if PHP was compiled with --enable-sigchild and the enhanced sigchild compatibility mode is not enabled * @throws ProcessFailedException if the process didn't terminate successfully */ - public function mustRun($callback = null) + public function mustRun(callable $callback = null) { if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) { throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.'); @@ -252,7 +252,7 @@ class Process * @throws RuntimeException When process is already running * @throws LogicException In case a callback is provided and output has been disabled */ - public function start($callback = null) + public function start(callable $callback = null) { if ($this->isRunning()) { throw new RuntimeException('Process is already running'); @@ -310,7 +310,7 @@ class Process * * @see start() */ - public function restart($callback = null) + public function restart(callable $callback = null) { if ($this->isRunning()) { throw new RuntimeException('Process is already running'); @@ -337,7 +337,7 @@ class Process * @throws RuntimeException When process stopped after receiving signal * @throws LogicException When process is not yet started */ - public function wait($callback = null) + public function wait(callable $callback = null) { $this->requireProcessIsStarted(__FUNCTION__); @@ -1232,7 +1232,7 @@ class Process * * @param callable|null $callback The user defined PHP callback * - * @return callable A PHP callable + * @return \Closure A PHP closure */ protected function buildCallback($callback) { diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index a39e8896d7..4bc71ca667 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -97,7 +97,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N /** * Set normalization callbacks. * - * @param array $callbacks help normalize the result + * @param callable[] $callbacks help normalize the result * * @return self * diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index de90d74aad..50b3956648 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -350,10 +350,10 @@ class PhpEngine implements EngineInterface, \ArrayAccess /** * Adds an escaper for the given context. * - * @param string $context The escaper context (html, js, ...) - * @param mixed $escaper A PHP callable + * @param string $context The escaper context (html, js, ...) + * @param callable $escaper A PHP callable */ - public function setEscaper($context, $escaper) + public function setEscaper($context, callable $escaper) { $this->escapers[$context] = $escaper; self::$escaperCache[$context] = array(); @@ -364,7 +364,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess * * @param string $context The context name * - * @return mixed $escaper A PHP callable + * @return callable $escaper A PHP callable * * @throws \InvalidArgumentException */ diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 79817803a2..c7f035de23 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -304,7 +304,7 @@ abstract class AbstractCloner implements ClonerInterface $a = $cast; } } catch (\Exception $e) { - $a[(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠'] = new ThrowingCasterException($callback, $e); + $a[(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠'] = new ThrowingCasterException($e); } return $a; diff --git a/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php b/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php index c1b427b92e..976f4439b6 100644 --- a/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php +++ b/src/Symfony/Component/VarDumper/Exception/ThrowingCasterException.php @@ -17,10 +17,9 @@ namespace Symfony\Component\VarDumper\Exception; class ThrowingCasterException extends \Exception { /** - * @param callable $caster The failing caster - * @param \Exception $prev The exception thrown from the caster + * @param \Exception $prev The exception thrown from the caster */ - public function __construct($caster, \Exception $prev) + public function __construct(\Exception $prev) { parent::__construct('Unexpected '.get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev); } diff --git a/src/Symfony/Component/VarDumper/VarDumper.php b/src/Symfony/Component/VarDumper/VarDumper.php index c728439df2..8c610c5d33 100644 --- a/src/Symfony/Component/VarDumper/VarDumper.php +++ b/src/Symfony/Component/VarDumper/VarDumper.php @@ -38,12 +38,8 @@ class VarDumper return call_user_func(self::$handler, $var); } - public static function setHandler($callable) + public static function setHandler(callable $callable = null) { - if (null !== $callable && !is_callable($callable, true)) { - throw new \InvalidArgumentException('Invalid PHP callback.'); - } - $prevHandler = self::$handler; self::$handler = $callable;