diff --git a/Debug/TraceableEventDispatcher.php b/Debug/TraceableEventDispatcher.php index f6b96bf..72ce526 100644 --- a/Debug/TraceableEventDispatcher.php +++ b/Debug/TraceableEventDispatcher.php @@ -76,7 +76,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber): void $this->dispatcher->removeSubscriber($subscriber); } - public function getListeners(string $eventName = null): array + public function getListeners(?string $eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -96,12 +96,12 @@ public function getListenerPriority(string $eventName, callable|array $listener) return $this->dispatcher->getListenerPriority($eventName, $listener); } - public function hasListeners(string $eventName = null): bool + public function hasListeners(?string $eventName = null): bool { return $this->dispatcher->hasListeners($eventName); } - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { $eventName ??= $event::class; @@ -136,7 +136,7 @@ public function dispatch(object $event, string $eventName = null): object return $event; } - public function getCalledListeners(Request $request = null): array + public function getCalledListeners(?Request $request = null): array { if (null === $this->callStack) { return []; @@ -154,7 +154,7 @@ public function getCalledListeners(Request $request = null): array return $called; } - public function getNotCalledListeners(Request $request = null): array + public function getNotCalledListeners(?Request $request = null): array { try { $allListeners = $this->dispatcher instanceof EventDispatcher ? $this->getListenersWithPriority() : $this->getListenersWithoutPriority(); @@ -196,7 +196,7 @@ public function getNotCalledListeners(Request $request = null): array return $notCalled; } - public function getOrphanedEvents(Request $request = null): array + public function getOrphanedEvents(?Request $request = null): array { if ($request) { return $this->orphanedEvents[spl_object_hash($request)] ?? []; diff --git a/EventDispatcher.php b/EventDispatcher.php index 65d8626..43bc16b 100644 --- a/EventDispatcher.php +++ b/EventDispatcher.php @@ -42,7 +42,7 @@ public function __construct() } } - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { $eventName ??= $event::class; @@ -59,7 +59,7 @@ public function dispatch(object $event, string $eventName = null): object return $event; } - public function getListeners(string $eventName = null): array + public function getListeners(?string $eventName = null): array { if (null !== $eventName) { if (empty($this->listeners[$eventName])) { @@ -108,7 +108,7 @@ public function getListenerPriority(string $eventName, callable|array $listener) return null; } - public function hasListeners(string $eventName = null): bool + public function hasListeners(?string $eventName = null): bool { if (null !== $eventName) { return !empty($this->listeners[$eventName]); diff --git a/EventDispatcherInterface.php b/EventDispatcherInterface.php index 6d4a5b4..99f8b1a 100644 --- a/EventDispatcherInterface.php +++ b/EventDispatcherInterface.php @@ -50,7 +50,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber): void; * * @return array */ - public function getListeners(string $eventName = null): array; + public function getListeners(?string $eventName = null): array; /** * Gets the listener priority for a specific event. @@ -62,5 +62,5 @@ public function getListenerPriority(string $eventName, callable $listener): ?int /** * Checks whether an event has any registered listeners. */ - public function hasListeners(string $eventName = null): bool; + public function hasListeners(?string $eventName = null): bool; } diff --git a/ImmutableEventDispatcher.php b/ImmutableEventDispatcher.php index f715ecb..a6d078e 100644 --- a/ImmutableEventDispatcher.php +++ b/ImmutableEventDispatcher.php @@ -23,7 +23,7 @@ public function __construct( ) { } - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { return $this->dispatcher->dispatch($event, $eventName); } @@ -48,7 +48,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber): never throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); } - public function getListeners(string $eventName = null): array + public function getListeners(?string $eventName = null): array { return $this->dispatcher->getListeners($eventName); } @@ -58,7 +58,7 @@ public function getListenerPriority(string $eventName, callable|array $listener) return $this->dispatcher->getListenerPriority($eventName, $listener); } - public function hasListeners(string $eventName = null): bool + public function hasListeners(?string $eventName = null): bool { return $this->dispatcher->hasListeners($eventName); }