mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Don't use php7 ReflectionGenerator in PHP5.x branch
This commit is contained in:
parent
e6f1386b31
commit
0255049bbb
@ -538,9 +538,10 @@ function __coroutineAdvance($cs) {
|
|||||||
} else {
|
} else {
|
||||||
$promisor = $cs->promisor;
|
$promisor = $cs->promisor;
|
||||||
$cs->promisor = null;
|
$cs->promisor = null;
|
||||||
$promisor->fail(new \DomainException(
|
$promisor->fail(new \DomainException(sprintf(
|
||||||
__generateYieldError($cs->generator, $key, $yielded)
|
"Unexpected Generator yield (Promise|null expected); %s yielded at key %s",
|
||||||
));
|
is_object($yielded) ? get_class($yielded) : gettype($yielded)
|
||||||
|
)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,20 +580,4 @@ function __coroutineSend($error, $result, $cs) {
|
|||||||
$promisor->fail($uncaught);
|
$promisor->fail($uncaught);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __generateYieldError(\Generator $generator, $key, $yielded) {
|
|
||||||
$reflectionGen = new \ReflectionGenerator($generator);
|
|
||||||
$executingGen = $reflectionGen->getExecutingGenerator();
|
|
||||||
if ($isSubgenerator = ($executingGen !== $generator)) {
|
|
||||||
$reflectionGen = new \ReflectionGenerator($executingGen);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf(
|
|
||||||
"Unexpected Generator yield (Promise|null expected); %s yielded at key %s on line %s in %s",
|
|
||||||
(is_object($yielded) ? get_class($yielded) : gettype($yielded)),
|
|
||||||
$key,
|
|
||||||
$reflectionGen->getExecutingLine(),
|
|
||||||
$reflectionGen->getExecutingFile()
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user