Skip to content

Commit f66cb4a

Browse files
committed
Check that factory returns an instance of LoopDriver
1 parent 30254b2 commit f66cb4a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Loop.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,21 @@ public static function execute(callable $callback, LoopDriver $driver = null)
5454
/**
5555
* Create a new driver if a factory is present, otherwise throw.
5656
*
57-
* @throws \LogicException if no factory is set
57+
* @throws \LogicException if no factory is set or no driver returned from factory
5858
*/
5959
private static function createDriver()
6060
{
6161
if (self::$factory === null) {
6262
throw new \LogicException("Can't create an event loop driver without a factory.");
6363
}
6464

65-
return self::$factory->create();
65+
$driver = self::$factory->create();
66+
67+
if (!$driver instanceof LoopDriver) {
68+
throw new \LogicException("LoopDriverFactory didn't return a LoopDriver.");
69+
}
70+
71+
return $driver;
6672
}
6773

6874
/**

0 commit comments

Comments
 (0)