diff --git a/Debug/TraceableEventDispatcher.php b/Debug/TraceableEventDispatcher.php index acfbf61..84d6a08 100644 --- a/Debug/TraceableEventDispatcher.php +++ b/Debug/TraceableEventDispatcher.php @@ -42,7 +42,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa private $requestStack; private $currentRequestHash = ''; - public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null, RequestStack $requestStack = null) + public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, ?LoggerInterface $logger = null, ?RequestStack $requestStack = null) { $this->dispatcher = $dispatcher; $this->stopwatch = $stopwatch; @@ -97,7 +97,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(?string $eventName = null) { return $this->dispatcher->getListeners($eventName); } @@ -123,7 +123,7 @@ public function getListenerPriority(string $eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(?string $eventName = null) { return $this->dispatcher->hasListeners($eventName); } @@ -131,7 +131,7 @@ public function hasListeners(string $eventName = null) /** * {@inheritdoc} */ - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { $eventName = $eventName ?? \get_class($event); @@ -171,7 +171,7 @@ public function dispatch(object $event, string $eventName = null): object /** * @return array */ - public function getCalledListeners(Request $request = null) + public function getCalledListeners(?Request $request = null) { if (null === $this->callStack) { return []; @@ -192,7 +192,7 @@ public function getCalledListeners(Request $request = null) /** * @return array */ - public function getNotCalledListeners(Request $request = null) + public function getNotCalledListeners(?Request $request = null) { try { $allListeners = $this->getListeners(); @@ -235,7 +235,7 @@ public function getNotCalledListeners(Request $request = null) 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/Debug/WrappedListener.php b/Debug/WrappedListener.php index 3c4cc13..80d49a1 100644 --- a/Debug/WrappedListener.php +++ b/Debug/WrappedListener.php @@ -33,7 +33,7 @@ final class WrappedListener private $priority; private static $hasClassStub; - public function __construct($listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null) + public function __construct($listener, ?string $name, Stopwatch $stopwatch, ?EventDispatcherInterface $dispatcher = null) { $this->listener = $listener; $this->optimizedListener = $listener instanceof \Closure ? $listener : (\is_callable($listener) ? \Closure::fromCallable($listener) : null); diff --git a/EventDispatcher.php b/EventDispatcher.php index 8fe8fb5..9c86bd9 100644 --- a/EventDispatcher.php +++ b/EventDispatcher.php @@ -45,7 +45,7 @@ public function __construct() /** * {@inheritdoc} */ - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { $eventName = $eventName ?? \get_class($event); @@ -65,7 +65,7 @@ public function dispatch(object $event, string $eventName = null): object /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(?string $eventName = null) { if (null !== $eventName) { if (empty($this->listeners[$eventName])) { @@ -120,7 +120,7 @@ public function getListenerPriority(string $eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(?string $eventName = null) { if (null !== $eventName) { return !empty($this->listeners[$eventName]); diff --git a/EventDispatcherInterface.php b/EventDispatcherInterface.php index cc324e1..4b65e5a 100644 --- a/EventDispatcherInterface.php +++ b/EventDispatcherInterface.php @@ -50,7 +50,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber); * * @return array */ - public function getListeners(string $eventName = null); + public function getListeners(?string $eventName = null); /** * Gets the listener priority for a specific event. @@ -66,5 +66,5 @@ public function getListenerPriority(string $eventName, callable $listener); * * @return bool */ - public function hasListeners(string $eventName = null); + public function hasListeners(?string $eventName = null); } diff --git a/ImmutableEventDispatcher.php b/ImmutableEventDispatcher.php index 568d79c..4e00bfa 100644 --- a/ImmutableEventDispatcher.php +++ b/ImmutableEventDispatcher.php @@ -28,7 +28,7 @@ public function __construct(EventDispatcherInterface $dispatcher) /** * {@inheritdoc} */ - public function dispatch(object $event, string $eventName = null): object + public function dispatch(object $event, ?string $eventName = null): object { return $this->dispatcher->dispatch($event, $eventName); } @@ -68,7 +68,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) /** * {@inheritdoc} */ - public function getListeners(string $eventName = null) + public function getListeners(?string $eventName = null) { return $this->dispatcher->getListeners($eventName); } @@ -84,7 +84,7 @@ public function getListenerPriority(string $eventName, $listener) /** * {@inheritdoc} */ - public function hasListeners(string $eventName = null) + public function hasListeners(?string $eventName = null) { return $this->dispatcher->hasListeners($eventName); }