提交的内容
This commit is contained in:
0
vendor/guzzlehttp/promises/src/AggregateException.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/AggregateException.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/CancellationException.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/CancellationException.php
vendored
Executable file → Normal file
4
vendor/guzzlehttp/promises/src/Coroutine.php
vendored
Executable file → Normal file
4
vendor/guzzlehttp/promises/src/Coroutine.php
vendored
Executable file → Normal file
@ -84,8 +84,8 @@ final class Coroutine implements PromiseInterface
|
||||
}
|
||||
|
||||
public function then(
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface {
|
||||
return $this->result->then($onFulfilled, $onRejected);
|
||||
}
|
||||
|
||||
0
vendor/guzzlehttp/promises/src/Create.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/Create.php
vendored
Executable file → Normal file
17
vendor/guzzlehttp/promises/src/Each.php
vendored
Executable file → Normal file
17
vendor/guzzlehttp/promises/src/Each.php
vendored
Executable file → Normal file
@ -19,14 +19,12 @@ final class Each
|
||||
* index, and the aggregate promise. The callback can invoke any necessary
|
||||
* side effects and choose to resolve or reject the aggregate if needed.
|
||||
*
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
*/
|
||||
public static function of(
|
||||
$iterable,
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface {
|
||||
return (new EachPromise($iterable, [
|
||||
'fulfilled' => $onFulfilled,
|
||||
@ -44,14 +42,12 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*/
|
||||
public static function ofLimit(
|
||||
$iterable,
|
||||
$concurrency,
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface {
|
||||
return (new EachPromise($iterable, [
|
||||
'fulfilled' => $onFulfilled,
|
||||
@ -67,12 +63,11 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
*/
|
||||
public static function ofLimitAll(
|
||||
$iterable,
|
||||
$concurrency,
|
||||
callable $onFulfilled = null
|
||||
?callable $onFulfilled = null
|
||||
): PromiseInterface {
|
||||
return self::ofLimit(
|
||||
$iterable,
|
||||
|
||||
8
vendor/guzzlehttp/promises/src/EachPromise.php
vendored
Executable file → Normal file
8
vendor/guzzlehttp/promises/src/EachPromise.php
vendored
Executable file → Normal file
@ -135,7 +135,7 @@ class EachPromise implements PromisorInterface
|
||||
|
||||
// Add only up to N pending promises.
|
||||
$concurrency = is_callable($this->concurrency)
|
||||
? call_user_func($this->concurrency, count($this->pending))
|
||||
? ($this->concurrency)(count($this->pending))
|
||||
: $this->concurrency;
|
||||
$concurrency = max($concurrency - count($this->pending), 0);
|
||||
// Concurrency may be set to 0 to disallow new promises.
|
||||
@ -170,8 +170,7 @@ class EachPromise implements PromisorInterface
|
||||
$this->pending[$idx] = $promise->then(
|
||||
function ($value) use ($idx, $key): void {
|
||||
if ($this->onFulfilled) {
|
||||
call_user_func(
|
||||
$this->onFulfilled,
|
||||
($this->onFulfilled)(
|
||||
$value,
|
||||
$key,
|
||||
$this->aggregate
|
||||
@ -181,8 +180,7 @@ class EachPromise implements PromisorInterface
|
||||
},
|
||||
function ($reason) use ($idx, $key): void {
|
||||
if ($this->onRejected) {
|
||||
call_user_func(
|
||||
$this->onRejected,
|
||||
($this->onRejected)(
|
||||
$reason,
|
||||
$key,
|
||||
$this->aggregate
|
||||
|
||||
4
vendor/guzzlehttp/promises/src/FulfilledPromise.php
vendored
Executable file → Normal file
4
vendor/guzzlehttp/promises/src/FulfilledPromise.php
vendored
Executable file → Normal file
@ -31,8 +31,8 @@ class FulfilledPromise implements PromiseInterface
|
||||
}
|
||||
|
||||
public function then(
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface {
|
||||
// Return itself if there is no onFulfilled function.
|
||||
if (!$onFulfilled) {
|
||||
|
||||
0
vendor/guzzlehttp/promises/src/Is.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/Is.php
vendored
Executable file → Normal file
8
vendor/guzzlehttp/promises/src/Promise.php
vendored
Executable file → Normal file
8
vendor/guzzlehttp/promises/src/Promise.php
vendored
Executable file → Normal file
@ -25,16 +25,16 @@ class Promise implements PromiseInterface
|
||||
* @param callable $cancelFn Fn that when invoked cancels the promise.
|
||||
*/
|
||||
public function __construct(
|
||||
callable $waitFn = null,
|
||||
callable $cancelFn = null
|
||||
?callable $waitFn = null,
|
||||
?callable $cancelFn = null
|
||||
) {
|
||||
$this->waitFn = $waitFn;
|
||||
$this->cancelFn = $cancelFn;
|
||||
}
|
||||
|
||||
public function then(
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface {
|
||||
if ($this->state === self::PENDING) {
|
||||
$p = new Promise(null, [$this, 'cancel']);
|
||||
|
||||
4
vendor/guzzlehttp/promises/src/PromiseInterface.php
vendored
Executable file → Normal file
4
vendor/guzzlehttp/promises/src/PromiseInterface.php
vendored
Executable file → Normal file
@ -27,8 +27,8 @@ interface PromiseInterface
|
||||
* @param callable $onRejected Invoked when the promise is rejected.
|
||||
*/
|
||||
public function then(
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface;
|
||||
|
||||
/**
|
||||
|
||||
0
vendor/guzzlehttp/promises/src/PromisorInterface.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/PromisorInterface.php
vendored
Executable file → Normal file
4
vendor/guzzlehttp/promises/src/RejectedPromise.php
vendored
Executable file → Normal file
4
vendor/guzzlehttp/promises/src/RejectedPromise.php
vendored
Executable file → Normal file
@ -31,8 +31,8 @@ class RejectedPromise implements PromiseInterface
|
||||
}
|
||||
|
||||
public function then(
|
||||
callable $onFulfilled = null,
|
||||
callable $onRejected = null
|
||||
?callable $onFulfilled = null,
|
||||
?callable $onRejected = null
|
||||
): PromiseInterface {
|
||||
// If there's no onRejected callback then just return self.
|
||||
if (!$onRejected) {
|
||||
|
||||
0
vendor/guzzlehttp/promises/src/RejectionException.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/RejectionException.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/TaskQueue.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/TaskQueue.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/TaskQueueInterface.php
vendored
Executable file → Normal file
0
vendor/guzzlehttp/promises/src/TaskQueueInterface.php
vendored
Executable file → Normal file
6
vendor/guzzlehttp/promises/src/Utils.php
vendored
Executable file → Normal file
6
vendor/guzzlehttp/promises/src/Utils.php
vendored
Executable file → Normal file
@ -21,7 +21,7 @@ final class Utils
|
||||
*
|
||||
* @param TaskQueueInterface|null $assign Optionally specify a new queue instance.
|
||||
*/
|
||||
public static function queue(TaskQueueInterface $assign = null): TaskQueueInterface
|
||||
public static function queue(?TaskQueueInterface $assign = null): TaskQueueInterface
|
||||
{
|
||||
static $queue;
|
||||
|
||||
@ -144,7 +144,9 @@ final class Utils
|
||||
$results[$idx] = $value;
|
||||
},
|
||||
function ($reason, $idx, Promise $aggregate): void {
|
||||
$aggregate->reject($reason);
|
||||
if (Is::pending($aggregate)) {
|
||||
$aggregate->reject($reason);
|
||||
}
|
||||
}
|
||||
)->then(function () use (&$results) {
|
||||
ksort($results);
|
||||
|
||||
Reference in New Issue
Block a user