| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +declare (strict_types=1); | |
| 3 | 4 | namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Promise; |
| 4 | 5 | |
| 5 | 6 | final class Each |
| 6 | 7 | { |
| @@ -16,15 +17,11 @@ | ||
| 16 | 17 | * $onRejected is a function that accepts the rejection reason, iterator |
| 17 | 18 | * index, and the aggregate promise. The callback can invoke any necessary |
| 18 | 19 | * side effects and choose to resolve or reject the aggregate if needed. |
| 19 | 20 | * |
| 20 | - * @param mixed $iterable Iterator or array to iterate over. | |
| 21 | - * @param callable $onFulfilled | |
| 22 | - * @param callable $onRejected | |
| 23 | - * | |
| 24 | - * @return PromiseInterface | |
| 21 | + * @param mixed $iterable Iterator or array to iterate over. | |
| 25 | 22 | */ |
| 26 | - public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null) | |
| 23 | + public static function of($iterable, ?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface | |
| 27 | 24 | { |
| 28 | 25 | return (new EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected]))->promise(); |
| 29 | 26 | } |
| 30 | 27 | /** |
| @@ -36,14 +33,10 @@ | ||
| 36 | 33 | * for dynamic a concurrency size. |
| 37 | 34 | * |
| 38 | 35 | * @param mixed $iterable |
| 39 | 36 | * @param int|callable $concurrency |
| 40 | - * @param callable $onFulfilled | |
| 41 | - * @param callable $onRejected | |
| 42 | - * | |
| 43 | - * @return PromiseInterface | |
| 44 | 37 | */ |
| 45 | - public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null) | |
| 38 | + public static function ofLimit($iterable, $concurrency, ?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface | |
| 46 | 39 | { |
| 47 | 40 | return (new EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected, 'concurrency' => $concurrency]))->promise(); |
| 48 | 41 | } |
| 49 | 42 | /** |
| @@ -52,15 +45,12 @@ | ||
| 52 | 45 | * rejected with the encountered rejection. |
| 53 | 46 | * |
| 54 | 47 | * @param mixed $iterable |
| 55 | 48 | * @param int|callable $concurrency |
| 56 | - * @param callable $onFulfilled | |
| 57 | - * | |
| 58 | - * @return PromiseInterface | |
| 59 | 49 | */ |
| 60 | - public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null) | |
| 50 | + public static function ofLimitAll($iterable, $concurrency, ?callable $onFulfilled = null) : PromiseInterface | |
| 61 | 51 | { |
| 62 | - return each_limit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, PromiseInterface $aggregate) { | |
| 52 | + return self::ofLimit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, PromiseInterface $aggregate) : void { | |
| 63 | 53 | $aggregate->reject($reason); |
| 64 | 54 | }); |
| 65 | 55 | } |
| 66 | 56 | } |