public function addEventListener(callable $listener): void
    {
        /** @var \Jasny\EventDispatcher\EventDispatcher $dispatcher */
        $dispatcher = type_check(
            $this->getEventDispatcher(),
            'Jasny\EventDispatcher\EventDispatcher',
            new LogicException('Unsupported event dispatcher. Please overload the addEventListener method.')
        );

        /** @var \Jasny\EventDispatcher\ListenerProvider $provider */
        $provider = type_check(
            $dispatcher->getListenerProvider(),
            'Jasny\EventDispatcher\ListenerProvider',
            new UnexpectedValueException('Unsupported listener provider; expected %2s, got %1s')
        );

        $newProvider = $provider->withListener($listener);
        $newDispatcher = $dispatcher->withListenerProvider($newProvider);

        $this->setEventDispatcher($newDispatcher);
    }