Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal Queue leftovers #238

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/Internal/FulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace React\Promise\Internal;

use React\Promise\Promise;
use React\Promise\PromiseInterface;
use function React\Promise\enqueue;
use function React\Promise\resolve;

/**
Expand All @@ -29,15 +27,11 @@ public function then(callable $onFulfilled = null, callable $onRejected = null):
return $this;
}

return new Promise(function (callable $resolve, callable $reject) use ($onFulfilled): void {
enqueue(function () use ($resolve, $reject, $onFulfilled): void {
try {
$resolve($onFulfilled($this->value));
} catch (\Throwable $exception) {
$reject($exception);
}
});
});
try {
return resolve($onFulfilled($this->value));
} catch (\Throwable $exception) {
return new RejectedPromise($exception);
}
}

public function catch(callable $onRejected): PromiseInterface
Expand Down
30 changes: 0 additions & 30 deletions src/Internal/Queue.php

This file was deleted.

16 changes: 5 additions & 11 deletions src/Internal/RejectedPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace React\Promise\Internal;

use React\Promise\Promise;
use React\Promise\PromiseInterface;
use function React\Promise\_checkTypehint;
use function React\Promise\enqueue;
use function React\Promise\resolve;

/**
Expand All @@ -26,15 +24,11 @@ public function then(callable $onFulfilled = null, callable $onRejected = null):
return $this;
}

return new Promise(function (callable $resolve, callable $reject) use ($onRejected): void {
enqueue(function () use ($resolve, $reject, $onRejected): void {
try {
$resolve($onRejected($this->reason));
} catch (\Throwable $exception) {
$reject($exception);
}
});
});
try {
return resolve($onRejected($this->reason));
} catch (\Throwable $exception) {
return new RejectedPromise($exception);
}
}

public function catch(callable $onRejected): PromiseInterface
Expand Down
14 changes: 0 additions & 14 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,6 @@ function (\Throwable $reason) use ($i, &$reasons, &$toReject, $reject, &$continu
}, $cancellationQueue);
}

/**
* @internal
*/
function enqueue(callable $task): void
{
static $queue;

if (!$queue) {
$queue = new Internal\Queue();
}

$queue->enqueue($task);
}

/**
* @internal
*/
Expand Down
70 changes: 0 additions & 70 deletions tests/Internal/QueueTest.php

This file was deleted.