Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | yes |
RFC? | no |
Symfony version | 3.3 (master) |
If you have the following:
services:
FooInterface: '@Foo1'
Foo1:
#...
Foo2:
#...
autowiring_types: ['FooInterface']
Bar:
class: Bar
autowire: true
With:
class Bar {
function __construct(FooInterface $foo) {...}
}
Then the situation is ambiguous for Bar
: should $foo
points to Foo1
or Foo2
.
In Symfony 3.2.1
at least, I've seen a case where $foo
points to Foo2
(i.e. the autowired type) but then if you do a $container->get('FooInterface')
you will have Foo1
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.