Skip to content

Commit 32f6534

Browse files
committed
bug symfony#23024 [EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null) (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null) | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- e7c4149 [EventDispatcher] Fix ContainerAwareEventDispatcher::hasListeners(null)
2 parents 78c4a5f + e7c4149 commit 32f6534

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function removeListener($eventName, $listener)
105105
public function hasListeners($eventName = null)
106106
{
107107
if (null === $eventName) {
108-
return (bool) count($this->listenerIds) || (bool) count($this->listeners);
108+
return $this->listenerIds || $this->listeners || parent::hasListeners();
109109
}
110110

111111
if (isset($this->listenerIds[$eventName])) {

src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function testAddListener()
5656
{
5757
$this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo'));
5858
$this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'));
59+
$this->assertTrue($this->dispatcher->hasListeners());
5960
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
6061
$this->assertTrue($this->dispatcher->hasListeners(self::postFoo));
6162
$this->assertCount(1, $this->dispatcher->getListeners(self::preFoo));

0 commit comments

Comments
 (0)