Terminate generators when YieldReturnValue is yielded

This commit is contained in:
Daniil Gentili 2018-12-27 11:59:48 +00:00
parent 5b83cd9322
commit f31af1d645

View File

@ -69,7 +69,7 @@ final class Coroutine implements Promise
if (!$yielded instanceof Promise) {
if ($yielded instanceof \YieldReturnValue) {
$this->resolve($yielded->getReturn());
$this->generator->next();
return;
}
if (!$this->generator->valid()) {
@ -115,6 +115,7 @@ final class Coroutine implements Promise
if ($yielded instanceof \YieldReturnValue) {
$this->resolve($yielded->getReturn());
$this->onResolve = null;
$this->generator->next();
return;
}