Issue #3232110 by daffie: [Symfony 6] Add type hints to the methods Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::getListeners(), ::getListenerPriority() and ::hasListeners()

merge-requests/1215/head
Lee Rowlands 2021-09-18 11:15:49 +10:00
parent d2e915504a
commit caeb32e866
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
1 changed files with 5 additions and 4 deletions

View File

@ -153,7 +153,7 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getListeners($event_name = NULL) { public function getListeners($event_name = NULL): array {
$result = []; $result = [];
if ($event_name === NULL) { if ($event_name === NULL) {
@ -193,9 +193,9 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getListenerPriority($event_name, $listener) { public function getListenerPriority($event_name, $listener): ?int {
if (!isset($this->listeners[$event_name])) { if (!isset($this->listeners[$event_name])) {
return; return NULL;
} }
if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) { if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
$listener[0] = $listener[0](); $listener[0] = $listener[0]();
@ -219,12 +219,13 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
} }
} }
} }
return NULL;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function hasListeners($event_name = NULL) { public function hasListeners($event_name = NULL): bool {
if ($event_name !== NULL) { if ($event_name !== NULL) {
return !empty($this->listeners[$event_name]); return !empty($this->listeners[$event_name]);
} }