Debug command makes using autowiring with EventSubscribers and EventListeners impossible
Closed this issue · 2 comments
At the moment when PopulateDebugCommandPass is executed AutowiringPass haven't been executed yet (first one works on PassConfig::TYPE_BEFORE_OPTIMIZATION phase and later one works on PassConfig::TYPE_OPTIMIZE phase of container building).
So when using $subscriber = $container->get($serviceId);
(PopulateDebugCommandPass.php:33) autowired services aren't ready to be fetched from container thus throwing next exception:
Too few arguments to function MyEventSubscriber::__construct(), 0 passed and exactly 3 expected
.
I suggest using reflection here to be sure that non-prepared services are fetched by that moment.
Thanks for reporting this issue. Would you like contributing to this project and preparing a PR?
Already done :)
I checked it and found out it is better just to change the phase instead of using reflection.
Priority of that compiler pass could be lowered too - just to ensure it is executed after other compiler passes.