Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45b2382

Browse files
committed
minor #15825 Fix potential access to undefined index (Seldaek)
This PR was merged into the 2.8 branch. Discussion ---------- Fix potential access to undefined index | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Fixes @Tobion's comment in https://github.com/symfony/symfony/pull/14563/files#r39705270 Commits ------- de41002 Fix potential access to undefined index
2 parents cfbda28 + de41002 commit 45b2382

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public function dispatch($eventName, Event $event = null)
5555
public function getListeners($eventName = null, $withPriorities = false)
5656
{
5757
if (true === $withPriorities) {
58-
return $eventName ? $this->listeners[$eventName] : array_filter($this->listeners);
58+
if (null !== $eventName) {
59+
return isset($this->listeners[$eventName]) ? $this->listeners[$eventName] : array();
60+
}
61+
62+
return array_filter($this->listeners);
5963
}
6064

6165
if (null !== $eventName) {

0 commit comments

Comments
 (0)