-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI][Autowiring] autowiring-types & FQCN #21772
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
Seems hard to fix without breaking bc (unless we consider this as a bug fix?). Edit: In fact if I remember well, aliases always win, so I guess it fixes the ambiguity? |
Prior to #21494 the aliases don't work for autowiring (at least interfaces, it might work to some degree with abstract or concrete classes), you have to use autowiring_types. And deprecating the later only comes with that PR as well. To be honest, even if there is a hard BC, it's such a confusing case it should be considered as a bug and be fixed still IMO. |
For me the behavior you describe isn't ambigus at all. Aliases and #21494 just add a new shortcut on top of this (and by the way make the syntax more concise by adding a new behavior to aliases). IMO, there is nothing to change in 3.2-. |
By the way, you cannot (and it was never allowed) to do A PR to add a method like |
I'm not following how it's not ambiguous. After #21494, if Prior to #21494, the case above simply doesn't work). And if I take the original example However #21494, we deprecate
Hm not sure where I implied that, I'm doing |
I don't understand why. How do you think it should behave? The current behavior looks perfectly logical to me but maybe it's not someone not aware of internal mechanisms. However the situation you describe should not be frequent, in 3.3 users should only use aliases and not use |
Clearly there is two ways to go:
Precisely. In insight, it wasn't that hard to debug: check
I hope non existent right now, unless you jump straight to master and mix both. However when someone will upgrade to 3.3, unless they diligently remove any usage of Thinking of your comment from before:
Admittedly this could help if you are using |
After some discussion off, in So two things:
|
If you have the following:
With:
Then the situation is ambiguous for
Bar
: should$foo
points toFoo1
orFoo2
.In Symfony
3.2.1
at least, I've seen a case where$foo
points toFoo2
(i.e. the autowired type) but then if you do a$container->get('FooInterface')
you will haveFoo1
which besides making the situation confusing makes it extremely hard to debug and detect.I cannot afford to upgrade on that project, so maybe this case is handled differently since #21494 has been merged, but I didn't see a test for that case in
master
and IHMO this is a case where a confusion remains and should throw an exception right off the bat and force the user to remove the ambiguity.The text was updated successfully, but these errors were encountered: