Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
Description
Symfony version(s) affected
6.3
Description
When the console commandlint:container
is invoked in debug mode, it recompiles the container with many compiler passes removed, includingResolveTaggedIteratorArgumentPass
andServiceLocatorTagPass
. As a result,RemoveUnusedDefinitionsPass
sees no references to tagged services and removes them as “unused”, unless those services are made public or otherwise referenced in the container. After those services are removed, theCheckTypeDeclarationsPass
pass does not see them and does not validate them.
The command behaves correctly in non-debug mode, but this is quite surprising and non-obvious.
How to reproduce
- create a service that uses
!tagged_iterator
to find its supporting services - create another service, tag it so the first service will find it
- intentionally configure incorrect arguments for this second service
- run the
lint:container
console command - observe that it did not detect those incorrect arguments
- mark the second service as public
- re-run
lint:container
- observe that incorrect arguments are now correctly detected
Repro example:https://github.com/DCoderLT/symfony_issue_53839 , the last service in config/services.yaml is configured incorrectly, butlint:container
does not detect it.
Possible Solution
If I add theResolveTaggedIteratorArgumentPass
andServiceLocatorTagPass
passes back into the linter command, the tagged services no longer get removed, so the bug gets fixed. But I am sure those passes were removed for a reason, and I don’t know if they depend on any other passes that have also been excluded from this command. So I am reluctant to suggest “add those two passes” as a complete/correct fix.
RemovingRemoveUnusedDefinitionsPass
also doesn’t seem like the correct fix.
Additional Context
No response