Terminate generators when YieldReturnValue is yielded
This commit is contained in:
parent
5b83cd9322
commit
f31af1d645
@ -69,7 +69,7 @@ final class Coroutine implements Promise
|
|||||||
if (!$yielded instanceof Promise) {
|
if (!$yielded instanceof Promise) {
|
||||||
if ($yielded instanceof \YieldReturnValue) {
|
if ($yielded instanceof \YieldReturnValue) {
|
||||||
$this->resolve($yielded->getReturn());
|
$this->resolve($yielded->getReturn());
|
||||||
|
$this->generator->next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->generator->valid()) {
|
if (!$this->generator->valid()) {
|
||||||
@ -115,6 +115,7 @@ final class Coroutine implements Promise
|
|||||||
if ($yielded instanceof \YieldReturnValue) {
|
if ($yielded instanceof \YieldReturnValue) {
|
||||||
$this->resolve($yielded->getReturn());
|
$this->resolve($yielded->getReturn());
|
||||||
$this->onResolve = null;
|
$this->onResolve = null;
|
||||||
|
$this->generator->next();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user