mirror of
https://github.com/danog/amp.git
synced 2024-12-02 17:37:50 +01:00
Fix use before init
This commit is contained in:
parent
80ecfe6b99
commit
eec21c12c6
@ -12,12 +12,12 @@ final class CombinedCancellationToken implements CancellationToken
|
|||||||
/** @var callable[] */
|
/** @var callable[] */
|
||||||
private array $callbacks = [];
|
private array $callbacks = [];
|
||||||
|
|
||||||
private ?CancelledException $exception;
|
private CancelledException $exception;
|
||||||
|
|
||||||
public function __construct(CancellationToken ...$tokens)
|
public function __construct(CancellationToken ...$tokens)
|
||||||
{
|
{
|
||||||
foreach ($tokens as $token) {
|
foreach ($tokens as $token) {
|
||||||
$id = $token->subscribe(function (CancelledException $exception) {
|
$id = $token->subscribe(function (CancelledException $exception): void {
|
||||||
$this->exception = $exception;
|
$this->exception = $exception;
|
||||||
|
|
||||||
$callbacks = $this->callbacks;
|
$callbacks = $this->callbacks;
|
||||||
@ -45,8 +45,8 @@ final class CombinedCancellationToken implements CancellationToken
|
|||||||
{
|
{
|
||||||
$id = $this->nextId++;
|
$id = $this->nextId++;
|
||||||
|
|
||||||
if ($this->exception) {
|
if (isset($this->exception)) {
|
||||||
Loop::defer(static fn (): Promise => call($callback)($this->exception));
|
Loop::defer(static fn (): Promise => call($callback, $this->exception));
|
||||||
} else {
|
} else {
|
||||||
$this->callbacks[$id] = $callback;
|
$this->callbacks[$id] = $callback;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user