1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

We need to check for Generator::getReturn() in ≥ PHP 7

This commit is contained in:
Bob Weinand 2015-06-13 18:37:04 +02:00
parent 8a8930c8fd
commit 298357f760

View File

@ -563,7 +563,13 @@ function resolve(\Generator $generator, Reactor $reactor = null, callable $promi
function __coroutineAdvance($cs) {
try {
if (!$cs->generator->valid()) {
$cs->promisor->succeed($cs->returnValue);
if (isset($cs->returnValue)) {
$cs->promisor->succeed($cs->returnValue);
} elseif (PHP_MAJOR_VERSION >= 7) {
$cs->promisor->succeed($cs->generator->getReturn());
} else {
$cs->promisor->succeed(null);
}
return;
}
$yielded = $cs->generator->current();