Explorar o código

Throw an exception if no listeners have been found for given event.

Max Gfeller %!s(int64=11) %!d(string=hai) anos
pai
achega
f1c1ba27b4
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/Composer/EventDispatcher/EventDispatcher.php

+ 4 - 0
src/Composer/EventDispatcher/EventDispatcher.php

@@ -118,6 +118,10 @@ class EventDispatcher
     {
         $listeners = $this->getListeners($event);
 
+        if(sizeof($listeners) === 0) {
+            throw new \InvalidArgumentException(sprintf('Script "%s" does not exist', $event->getName()));
+        }
+
         foreach ($listeners as $callable) {
             if (!is_string($callable) && is_callable($callable)) {
                 call_user_func($callable, $event);