You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MyHandler {
publicfunction__construct(privateSomeDependency$dep) {}
publicfunction__invoke(MyCommand$command) {}
}
class MyCommand {
publicfunction__construct(publicstring$name) {}
}
class MyController {
publicfunction__invoke() {
$this->commandBus->dispatch(newMyCommand('Ruud'));
}
}
The above should return in no dead classes.
But when MyCommand is not dispatched anywhere, it should mark MyHandler + MyCommand as dead.
Same with an Event and multiple event subscribers to that event. If the event is never dispatched, the event + all the subscribers should be marked as dead.
I believe that in order to support this (and #83), we need some HiddenCallProvider which will be based on AST, not based on reflection like EntrypointProvider is.
Since 0.7.0, we can deduce usages from AST, but I'm still unsure if it can solve this problem.
Because when we are analysing $this->commandBus->dispatch, we would need to know which handler have the MyCommand in its __invoke method to be able to mark it as used. This is possible in PHPStan only via collectors, which might be really tricky to inject into dead-code-detector's extension point without breaking its performance (mainly because you MUST NOT use reflection in all CollectedData rules).
Or do you see any option without collector-like logic?
Let's say you have the following:
The above should return in no dead classes.
But when MyCommand is not dispatched anywhere, it should mark MyHandler + MyCommand as dead.
Same with an Event and multiple event subscribers to that event. If the event is never dispatched, the event + all the subscribers should be marked as dead.
https://symfony.com/doc/current/components/messenger.html
The text was updated successfully, but these errors were encountered: