From f1c1ba27b4456adbf9c3ab38be9c7c5f5e4f1282 Mon Sep 17 00:00:00 2001 From: Max Gfeller Date: Thu, 19 Dec 2013 07:58:58 +0100 Subject: [PATCH] Throw an exception if no listeners have been found for given event. --- src/Composer/EventDispatcher/EventDispatcher.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 9c2aee91f..2f19673c4 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/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);