mirror of
https://github.com/doctrine/event-manager.git
synced 2026-03-23 22:32:21 +01:00
Merge branch '1.2.x' into 2.0.x
* 1.2.x: Failsafe for unknown event (#61)
This commit is contained in:
@@ -51,7 +51,7 @@ class EventManager
|
||||
*/
|
||||
public function getListeners(string $event): array
|
||||
{
|
||||
return $this->listeners[$event];
|
||||
return $this->listeners[$event] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,6 +91,11 @@ class EventManagerTest extends TestCase
|
||||
self::assertNull($reflection->getValue(null));
|
||||
}
|
||||
|
||||
public function testEmptyListenersListForUnregisteredEvent(): void
|
||||
{
|
||||
self::assertSame([], $this->eventManager->getListeners('unknown'));
|
||||
}
|
||||
|
||||
/* Listener methods */
|
||||
|
||||
public function preFoo(EventArgs $e): void
|
||||
|
||||
Reference in New Issue
Block a user