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

Declare variables as static within function

This commit is contained in:
Aaron Piotrowski 2019-05-20 14:10:59 -05:00
parent 944a2dd29d
commit 5dcdd83959

View File

@ -72,20 +72,20 @@ final class Coroutine implements Promise
return; return;
} }
/** @var bool Used to control iterative coroutine continuation. */
$immediate = true;
/** @var \Throwable|null Promise failure reason when executing next coroutine step, null at all other times. */
$exception = null;
/** @var mixed Promise success value when executing next coroutine step, null at all other times. */
$value = null;
/** /**
* @param \Throwable|null $e Exception to be thrown into the generator. * @param \Throwable|null $e Exception to be thrown into the generator.
* @param mixed $v Value to be sent into the generator. * @param mixed $v Value to be sent into the generator.
*/ */
$onResolve = function ($e, $v) use ($generator, &$exception, &$value, &$immediate, &$onResolve) { $onResolve = function ($e, $v) use ($generator, &$onResolve) {
/** @var bool Used to control iterative coroutine continuation. */
static $immediate = true;
/** @var \Throwable|null Promise failure reason when executing next coroutine step, null at all other times. */
static $exception;
/** @var mixed Promise success value when executing next coroutine step, null at all other times. */
static $value;
$exception = $e; $exception = $e;
$value = $v; $value = $v;
@ -137,7 +137,7 @@ final class Coroutine implements Promise
try { try {
$yielded->onResolve($onResolve); $yielded->onResolve($onResolve);
unset($generator, $yielded, $exception, $value, $immediate, $onResolve); unset($generator, $yielded, $onResolve);
} catch (\Throwable $e) { } catch (\Throwable $e) {
Loop::defer(static function () use ($e) { Loop::defer(static function () use ($e) {
throw $e; throw $e;