Browse Source

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

Jordi Boggiano 7 years ago
parent
commit
e37e7f1329
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/Composer/EventDispatcher/EventDispatcher.php

+ 6 - 1
src/Composer/EventDispatcher/EventDispatcher.php

@@ -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)) {