minor #40930 [DependencyInjection] Better exception when a configurator is not type hinted (lyrixx)

This PR was merged into the 5.3-dev branch.

Discussion
----------

[DependencyInjection] Better exception when a configurator is not type hinted

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

This would help with such BC break:
https://github.com/markitosgv/JWTRefreshTokenBundle/pull/241

Commits
-------

25813e3804 [DependencyInjection] Better exception when a configurator is not type hinted
This commit is contained in:
Fabien Potencier 2021-05-09 17:44:29 +02:00
commit 3c7662507d

View File

@ -102,7 +102,7 @@ class PhpFileLoader extends FileLoader
foreach ($parameters as $parameter) {
$reflectionType = $parameter->getType();
if (!$reflectionType instanceof \ReflectionNamedType) {
throw new \InvalidArgumentException(sprintf('Could not resolve argument "$%s" for "%s".', $parameter->getName(), $path));
throw new \InvalidArgumentException(sprintf('Could not resolve argument "$%s" for "%s". You must typehint it (for example with "%s" or "%s").', $parameter->getName(), $path, ContainerConfigurator::class, ContainerBuilder::class));
}
$type = $reflectionType->getName();