> $listenerMap */ public function __construct( private readonly array $listenerMap, private readonly AppContainer $container ) { } /** * @param array $payload */ public function dispatch(string $event, array $payload): void { $listeners = $this->listenerMap[$event] ?? []; foreach ($listeners as $descriptor) { try { $class = $descriptor['class']; $method = $descriptor['method']; $listener = $this->container->get($class); if (!$listener instanceof EventListener) { $listener = new $class(); } $listener->{$method}($event, $payload); } catch (\Throwable) { // Swallow — one failing listener must not break the chain. } } } }