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

[DependencyInjection] Target attribute with invalid name should throw exception #45020

Copy link
Copy link
Closed
@kbond

Description

@kbond
Issue body actions

Symfony version(s) affected

5.3+

Description

There is nothing stopping you from using an invalid name for the Target DI attribute.

How to reproduce

public function __construct(#[Target('someLogger')] LoggerInterface $logger)

In the above example, autowiring is not configured for Psr\Log\LoggerInterface $someLogger, the default logger is injected. I can imagine a scenario where you have a service injected but after an upgrade, the name is no longer valid so it is silently swapped for the default.

Possible Solution

I think the Target name should be validated when building the container and an exception thrown if invalid.

Additional Context

No response

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

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