8000 [DI][Autowiring] autowiring-types & FQCN · Issue #21772 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DI][Autowiring] autowiring-types & FQCN #21772
Closed
@theofidry

Description

@theofidry
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0