From c71a48beff9aea058b5a12c8aac4ef7210e31034 Mon Sep 17 00:00:00 2001 From: Helmut Januschka Date: Wed, 8 Jan 2020 13:46:12 +0100 Subject: [PATCH 1/3] fix empty prio --- src/Symfony/Component/EventDispatcher/EventDispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index c0f839b9db905..fbf69ffe31dec 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -94,7 +94,7 @@ public function getListeners(string $eventName = null) public function getListenerPriority(string $eventName, $listener) { if (empty($this->listeners[$eventName])) { - return null; + return 0; } if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure && 2 >= \count($listener)) { @@ -114,7 +114,7 @@ public function getListenerPriority(string $eventName, $listener) } } - return null; + return 0; } /** From 164da0d2e6b50833ae171f23dddb3ae631433349 Mon Sep 17 00:00:00 2001 From: Helmut Januschka Date: Wed, 8 Jan 2020 14:06:31 +0100 Subject: [PATCH 2/3] fix tests --- .../Component/EventDispatcher/Tests/EventDispatcherTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index ea9fe8c1b6cdc..5d3e4caf1cb09 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -123,8 +123,8 @@ public function testGetListenerPriority() $this->assertSame(-10, $this->dispatcher->getListenerPriority('pre.foo', $listener1)); $this->assertSame(0, $this->dispatcher->getListenerPriority('pre.foo', $listener2)); - $this->assertNull($this->dispatcher->getListenerPriority('pre.bar', $listener2)); - $this->assertNull($this->dispatcher->getListenerPriority('pre.foo', function () {})); + $this->assertEquals($this->dispatcher->getListenerPriority('pre.bar', $listener2), 0); + $this->assertEquals($this->dispatcher->getListenerPriority('pre.foo', function () {}), 0); } public function testDispatch() From 73ac2f3612f6cfcfadd5ee8022a14b2e37d2c806 Mon Sep 17 00:00:00 2001 From: Helmut Januschka Date: Wed, 8 Jan 2020 15:12:24 +0100 Subject: [PATCH 3/3] fix doc --- .../Component/EventDispatcher/EventDispatcherInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index 88c707c9a360b..8f25e162e06f6 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -62,7 +62,7 @@ public function getListeners(string $eventName = null); * * @param callable $listener The listener * - * @return int|null The event listener priority + * @return int The event listener priority, defaults to 0 */ public function getListenerPriority(string $eventName, $listener);