-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Autowiring deprecations after upgrading to 3.3.0 #22951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think you simply missed it using the 3.3.0-RC1 release actually. ^^ (I double-checked and it happens in both RC and stable release). You should probably typehint over But the question is: should we declare explicit aliases for those implementations? |
Defining the alias for the interface rather than the implementation was done on purpose, to encourage people to typehint interfaces. @weaverryan shouldn't the exception message also mention the existing supported interface autowiring to suggest changing the typehint ? I thought you added something about it. |
Now I'm seeing another deprecation (that was reported on Symfony Slack by other users too):
|
…nagi) This PR was merged into the master branch. Discussion ---------- Fix autowiring type deprec & use ConsoleEvents::ERROR Relates to symfony/symfony#22951 + use `ConsoleEvents::ERROR` rather than `ConsoleEvents::EXCEPTION` Commits ------- 4ebe39b Fix autowiring type deprec & use ConsoleEvents::ERROR
Autowiring-types are deprecated since Symfony 3.3 and will be removed in 4.0. Use aliases instead for "Psr\Log\LoggerInterface". This is from my appDevDebugProjectContainer.xml (only one single place where I found autowiring-type entry)
|
@mkalisz77 Your issue is probably solved by updating MonologBundle to 3.1 (which contains the fix from symfony/monolog-bundle#203). |
@javiereguiluz The |
I did have a PR with this change... but it was ultimately reverted: #22648 (comment) The proper fix is really to change the type-hint - e.g. But, this did confuse me, and is now confusing other people. My proposed message looked like this:
I believe that - at least now - we don't have a lot of context as to exactly where the type-hint is (i.e. which argument of which method). |
See #22999 |
This PR was merged into the 3.3 branch. Discussion ---------- Better DI type deprecation message | Q | A | ------------- | --- | Branch? | 3,3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22951 | License | MIT | Doc PR | n/a This is the most common autowiring deprecation: ```php public function __construct(UserPasswordEncoder $encoder) ``` You *should* type-hint `UserPasswordEncoderInterface` Current deprecation message: > Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won’t be supported in version 4.0. You should rename (or alias) the "security.user_password_encoder.generic" service to "Symfony\Component\Security\Core\Encoder\UserPasswordEncoder" instead. Updated message: > Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. Try changing the type-hint for argument "$encoder" of method "AppBundle\Service\TestServiceSubscriber::__construct()" to "Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface" instead. This only happens if we detect that there is a service/alias in the container (e.g. `...\UserPasswordEncoderInterface`) for the type-hint (`...\UserPasswordEncoder)`. Otherwise, if there is no correct type-hint in the container, we give the old recommendation (about aliasing). The only complex case (of giving good directions on *where* to fix things) is with a class that implements `ServiceSubscriberInterface` (where the type-hint is in the `getSusbcribedServices()` method). In that case, the notice is: > Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. Try changing the type-hint for "Symfony\Component\Security\Core\Encoder\UserPasswordEncoder" in "AppBundle\Service\TestServiceSubscriber" to "Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface" instead. Commits ------- a990d5c Improving deprecation message when hitting the "deprecated type" lookup, but an alias is available
…nagi) This PR was merged into the master branch. Discussion ---------- Fix autowiring type deprec & use ConsoleEvents::ERROR Relates to symfony/symfony#22951 + use `ConsoleEvents::ERROR` rather than `ConsoleEvents::EXCEPTION` Commits ------- 4ebe39b Fix autowiring type deprec & use ConsoleEvents::ERROR
…nagi) This PR was merged into the master branch. Discussion ---------- Fix autowiring type deprec & use ConsoleEvents::ERROR Relates to symfony/symfony#22951 + use `ConsoleEvents::ERROR` rather than `ConsoleEvents::EXCEPTION` Commits ------- 4ebe39b Fix autowiring type deprec & use ConsoleEvents::ERROR
After upgrading the Symfony Demo app to 3.3.0 final, I see these deprecations (that weren't shown in 3.3.0 RC1):
The text was updated successfully, but these errors were encountered: