8000 [DI] Autowiring fails when TypeHinting on interfaces implemented indirectly · Issue #18658 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DI] Autowiring fails when TypeHinting on interfaces implemented indirectly #18658
Closed
@lemoinem

Description

@lemoinem

The current implementation of autowiring seems to force unnecessary coupling and to be instable in case of change in a vendor's service implementation.

Example 1:

interface IA
interface IB extends IA
*service* class C implemets IB

I can autowire using the type hint IB, but not IA.

Example 2:

interface I
class CA implements I
*service* class CB extends CA

I cannot type hint on I.

This means, autowiring would break if an intermediary interface or an abstract class were added. Nothing in the documentation (http://symfony.com/doc/current/components/dependency_injection/autowiring.html) mentions this limitation and it seems highly counter-intuitive.

If you agree this should be addressed, I am ready to provide a PR to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DependencyInjectionRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0