[HttpKernel] ControllerResolver arguments reflection for Closure object.

When controller is a Closure ControllerResolver::getArguments tries to
make a ReflectionMethod of the __invoke method. But because it's an
internal function, the parameters method isDefaultValueAvailable will
return always false, even if isOptional return true.
This commit is contained in:
Juan M Martínez 2011-11-22 14:52:21 +01:00 committed by Fabien Potencier
parent 5878490b16
commit 61e0bdebf8

View File

@ -96,8 +96,12 @@ class ControllerResolver implements ControllerResolverInterface
if (is_array($controller)) {
$r = new \ReflectionMethod($controller[0], $controller[1]);
} elseif (is_object($controller)) {
$r = new \ReflectionObject($controller);
$r = $r->getMethod('__invoke');
if ($controller instanceof \Closure) {
$r = new \ReflectionFunction($controller);
} else {
$r = new \ReflectionObject($controller);
$r = $r->getMethod('__invoke');
}
} else {
$r = new \ReflectionFunction($controller);
}