From f66cb4a66f732cf1fd50214e4c8b13a5500d9323 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sun, 15 May 2016 20:18:45 +0200 Subject: [PATCH] Check that factory returns an instance of LoopDriver --- src/Loop.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Loop.php b/src/Loop.php index eceb847..d29b989 100644 --- a/src/Loop.php +++ b/src/Loop.php @@ -54,7 +54,7 @@ final class Loop /** * Create a new driver if a factory is present, otherwise throw. * - * @throws \LogicException if no factory is set + * @throws \LogicException if no factory is set or no driver returned from factory */ private static function createDriver() { @@ -62,7 +62,13 @@ final class Loop throw new \LogicException("Can't create an event loop driver without a factory."); } - return self::$factory->create(); + $driver = self::$factory->create(); + + if (!$driver instanceof LoopDriver) { + throw new \LogicException("LoopDriverFactory didn't return a LoopDriver."); + } + + return $driver; } /**