浏览代码

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

Jordi Boggiano 7 年之前
父节点
当前提交
e37e7f1329
共有 1 个文件被更改,包括 6 次插入1 次删除
  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)) {