1
0
Fork 0

Fix handling of non-callable event listeners, fixes #7229

pull/6683/merge
Jordi Boggiano 2018-04-13 10:43:39 +02:00
parent 785aba9d82
commit e37e7f1329
1 changed files with 6 additions and 1 deletions

View File

@ -166,7 +166,12 @@ class EventDispatcher
$return = 0;
foreach ($listeners as $callable) {
if (!is_string($callable) && is_callable($callable)) {
if (!is_string($callable)) {
if (!is_callable($callable)) {
$className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
}
$event = $this->checkListenerExpectedEvent($callable, $event);
$return = false === call_user_func($callable, $event) ? 1 : 0;
} elseif ($this->isComposerScript($callable)) {