From c377a99e44fd968381d945c8b6735c6df934925a Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 2 Sep 2022 10:40:35 +0100 Subject: [PATCH 1/3] Restore support for arguments as arrays. --- .../HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php index 5022180e77c62..789428e3ab475 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php @@ -21,6 +21,10 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface public function createArgumentMetadata(string|object|array $controller, \ReflectionClass $class = null, \ReflectionFunctionAbstract $reflection = null): array { $arguments = []; + if (\is_array($controller)) { + $reflection = new \ReflectionMethod($controller[0], $controller[1]); + $class = $reflection->class; + } if (null === $reflection) { $reflection = new \ReflectionFunction($controller(...)); From 3aff61678cc886237b530748592c5b0fc3eac2a5 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 2 Sep 2022 11:12:19 +0100 Subject: [PATCH 2/3] Revert "Restore support for arguments as arrays." This reverts commit c377a99e44fd968381d945c8b6735c6df934925a. --- .../HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php index 789428e3ab475..5022180e77c62 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadataFactory.php @@ -21,10 +21,6 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface public function createArgumentMetadata(string|object|array $controller, \ReflectionClass $class = null, \ReflectionFunctionAbstract $reflection = null): array { $arguments = []; - if (\is_array($controller)) { - $reflection = new \ReflectionMethod($controller[0], $controller[1]); - $class = $reflection->class; - } if (null === $reflection) { $reflection = new \ReflectionFunction($controller(...)); From 9aa1815f5be3159c79e6370cee4234b3606e2092 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 2 Sep 2022 11:13:12 +0100 Subject: [PATCH 3/3] Don't send reflectors if there aren't any, not even an empty array. --- .../Component/HttpKernel/Controller/ArgumentResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php index cf690aa9291be..27f2dd8927a37 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver.php @@ -43,7 +43,7 @@ public function __construct(ArgumentMetadataFactoryInterface $argumentMetadataFa public function getArguments(Request $request, callable $controller): array { $arguments = []; - $reflectors = $request->attributes->get('_controller_reflectors') ?? []; + $reflectors = $request->attributes->get('_controller_reflectors') ?? NULL; foreach ($this->argumentMetadataFactory->createArgumentMetadata($controller, ...$reflectors) as $metadata) { foreach ($this->argumentValueResolvers as $resolver) {