From dec1db920638c20cb081dc8ccd50af67dc8fc40b Mon Sep 17 00:00:00 2001 From: Nyholm Date: Tue, 5 Nov 2019 16:23:18 +0100 Subject: [PATCH 1/2] Throw better exception when missing use-statement --- .../RegisterControllerArgumentLocatorsPass.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index d021c6ee8a126..0ddc22439d2eb 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -65,6 +65,14 @@ public function process(ContainerBuilder $container) $class = $parameterBag->resolveValue($class); if (!$r = $container->getReflectionClass($class)) { + if ($id === $class) { + /* + * This happens when container has not been built before and if $class is missing some use-statements. + * Make sure PHP loads the file to show any exceptions the user. + */ + class_exists($class); + } + throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); } $isContainerAware = $r->implementsInterface(ContainerAwareInterface::class) || is_subclass_of($class, AbstractController::class); From 37423eee684d4e3f1fe9c7333314c98635d10eb7 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 6 Nov 2019 17:41:49 +0100 Subject: [PATCH 2/2] typo --- .../RegisterControllerArgumentLocatorsPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index 0ddc22439d2eb..64d683a37ba70 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -68,7 +68,7 @@ public function process(ContainerBuilder $container) if ($id === $class) { /* * This happens when container has not been built before and if $class is missing some use-statements. - * Make sure PHP loads the file to show any exceptions the user. + * Make sure PHP loads the file to show any exceptions to the user. */ class_exists($class); }