From d9aa8573f0145752b2ea33ff861847c4620cb1e9 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Wed, 11 May 2016 18:49:25 +0200 Subject: [PATCH] Throw InvalidArgumentException if argument to resolve() is neither callable nor an instance of Generator --- lib/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/functions.php b/lib/functions.php index d704144a..b9523132 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -757,10 +757,12 @@ function coroutine(callable $func) { */ function resolve($generator) { if (!$generator instanceof \Generator) { - if (is_callable($generator)) { - $generator = call_user_func($generator); + if (!is_callable($generator)) { + throw new \InvalidArgumentException('Coroutine to resolve must be callable or instance of Generator'); } + $generator = call_user_func($generator); + if (!$generator instanceof \Generator) { throw new \LogicException('Callable passed to resolve() did not return an instance of Generator'); }