Description
Symfony version(s) affected: 4.3.1
Description
I have an exception when I try to dispatch an event from event dispatcher service, the current exception is:
Argument 1 passed to "Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch()" must be an instance of Symfony\Component\EventDispatcher\Event, MyBundle\Event\MyEvent given.
PhpStorm shows "Symfony\Component\EventDispatcher\Event" as deprecated and suggest to use "Symfony\Contracts\EventDispatcher\Event" class but throw the previous exception.
My event class
<php
use Symfony\Contracts\EventDispatcher\Event;
class MyEvent extends Event
{
//my custom code
}
How to reproduce
Follow the steps below in order to reproduce the exception:
//this code is in a controller class
$this->get('event_dispatcher')->dispatch('myevent', new MyEvent(/*constructor parameters if proceed*/));
If inheritance if changed for "Symfony\Component\EventDispatcher\Event" instead of "Symfony\Contracts\EventDispatcher\Event" works like charm.
I'm not sure if is really a bug or is my code.
Any idea?
Thank you! in advance.