Skip to content

Commit

Permalink
[HttpKernel] ControllerResolver arguments reflection for Closure object.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ju-mar authored and fabpot committed Nov 24, 2011
1 parent 5878490 commit 61e0bde
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -96,8 +96,12 @@ public function getArguments(Request $request, $controller)
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);
}
Expand Down

0 comments on commit 61e0bde

Please sign in to comment.