composer require zarganwar/symfony-event-dispatcher-utils
- Install this lib
- Create Subscriber with __invoke method and with typed $event parameter
- Type of parameter must be a class, interface or union types
- Declare use Trait from this package
- Enjoy 😉
class CoolSubscriber implements Symfony\Component\EventDispatcher\EventSubscriberInterface
{
use Zarganwar\SymfonyEventDispatcherUtils\AutoEventSubscriberTrait;
public function __invoke(CoolEvent $event): void
{
// Be Cool
}
}