Skip to content

Commit

Permalink
Declare variables as static within function
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed May 31, 2019
1 parent 944a2dd commit 5dcdd83
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/Coroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ public function __construct(\Generator $generator)
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 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;
$value = $v;

Expand Down Expand Up @@ -137,7 +137,7 @@ public function __construct(\Generator $generator)
try {
$yielded->onResolve($onResolve);

unset($generator, $yielded, $exception, $value, $immediate, $onResolve);
unset($generator, $yielded, $onResolve);
} catch (\Throwable $e) {
Loop::defer(static function () use ($e) {
throw $e;
Expand Down

0 comments on commit 5dcdd83

Please sign in to comment.