Skip to content

Commit 9143330

Browse files
committed
[HttpKernel][DX] Improve the error message when not defining the controller as a service but using contruct parameters
1 parent a20fee4 commit 9143330

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Controller/ContainerControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function instantiateController($class)
5959
$this->throwExceptionIfControllerWasRemoved($class, $e);
6060

6161
if ($e instanceof \ArgumentCountError) {
62-
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define such a service?', $class), 0, $e);
62+
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e);
6363
}
6464

6565
throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e);

Tests/Controller/ContainerControllerResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,16 @@ public function getUndefinedControllers()
184184
$tests[] = [
185185
[ControllerTestService::class, 'action'],
186186
\InvalidArgumentException::class,
187-
'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
187+
'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?',
188188
];
189189
$tests[] = [
190190
ControllerTestService::class.'::action',
191-
\InvalidArgumentException::class, 'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
191+
\InvalidArgumentException::class, 'Controller "Symfony\Component\HttpKernel\Tests\Controller\ControllerTestService" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?',
192192
];
193193
$tests[] = [
194194
InvokableControllerService::class,
195195
\InvalidArgumentException::class,
196-
'Controller "Symfony\Component\HttpKernel\Tests\Controller\InvokableControllerService" has required constructor arguments and does not exist in the container. Did you forget to define such a service?',
196+
'Controller "Symfony\Component\HttpKernel\Tests\Controller\InvokableControllerService" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?',
197197
];
198198

199199
return $tests;

0 commit comments

Comments
 (0)