Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #22648 Improving autowire exception when you type-hint a class …
…& alias is available (weaverryan) This PR was merged into the 3.3-dev branch. Discussion ---------- Improving autowire exception when you type-hint a class & alias is available | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | n/a Suppose you type-hint a class instead of the correct interface (which is aliased): ```php public function __construct(Logger $logger) ``` Current error: > Cannot autowire service "AppBundle\Security\PostVoter": argument "$logger" of method "__construct()" references class "Symfony\Bridge\Monolog\Logger" but no such service exists. You should maybe alias this class to one of these existing services: "monolog.logger", "monolog.logger.request", "monolog.logger.console", "monolog.logger.cache", "monolog.logger.templating", "monolog.logger.translation", "monolog.logger.profiler", "monolog.logger.php", "monolog.logger.event", "monolog.logger.router", "monolog.logger.security", "monolog.logger.doctrine"; or type-hint against interface "Psr\Log\LoggerInterface" instead. New error: > Cannot autowire service "AppBundle\Security\PostVoter": argument "$logger" of method "__construct()" references class "Symfony\Bridge\Monolog\Logger" but no such service exists. Try changing the type-hint to "Psr\Log\LoggerInterface" instead. The correct "suggestion" was always there (at the end). I think if there is already a definitive alias available for your type-hint, we can say that they are simply using the wrong type-hint and suggest *only* that. Commits ------- 5a3c156 Improving autowire exception when you type-hint a class and there is an interface alias available
- Loading branch information