mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
Throw InvalidArgumentException if argument to resolve() is neither callable nor an instance of Generator
This commit is contained in:
parent
92e004264c
commit
d9aa8573f0
@ -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');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user