Closed
Description
Symfony version(s) affected: symfony/messenger: ^5
Description
Currently the symfony/messenger
has no dependency in composer.json to symfony/event-dispatcher
, but the Code internally relies on Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy
and is not replaceable by e.G. just using the event-dispatcher-contracts
as dependency.
See:
Symfony\Component\Messenger\Worker
- https://github.com/symfony/messenger/blob/39444584eaec8a351da331e519d705931aa97235/Worker.php#L50Symfony\Component\Messenger\Middleware\SendMessageMiddleware
- https://github.com/symfony/messenger/blob/5c2a1563ad7cae9f4b51a7d968f179a576ae840e/Middleware/SendMessageMiddleware.php#L38
How to reproduce
Send a Message asynchronously without having symfony/event-dispatcher
as dependency. 💥
Possible Solution
v1: Add symfony/event-dispatcher
as require
in composer.json
v2 (prefered): Use the injected Symfony\Contracts\EventDispatcher\EventDispatcherInterface
correctly without relying on the LegacyEventDispatcherProxy
-class to be there.