Description
Symfony version(s) affected: 4.4.0
Description
The EventDispatcherInterface
currently allows dispatching event by its name only (dispatch($eventName)
) or by supplying the event and its name (dispatch($event, $eventName)
).
In the second case, when the arguments are swapped, an incorrect error will be returned in some cases. Specifically, it will be incorrect when the event will be a subclass of Symfony\Contracts\EventDispatcher\Event
as opposed to a subclass of Symfony\Component\EventDispatcher\Event
(the latter has been deprecated since 4.3).
How to reproduce
Attempt to dispatch an event that is a subclass of Symfony\Contracts\EventDispatcher\Event
and swap the arguments (provide event name first, its object second).
Possible Solution
The line in
Additional context
This issue is only valid for the 4.4 branch (and maybe 4.3?). In 5.0, EventDispatcher
doesn't contain the code in question.