Closed
Closed
Copy link
Description
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