Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DI] Autowiring fails when TypeHinting on interfaces implemented indirectly #18658

Copy link
Copy link
Closed
@lemoinem

Description

@lemoinem
Issue body actions

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)DX = Developer eXperience (anything that improves the experience of using Symfony)DependencyInjectionRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = 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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.