PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | vendor_prefixed/guzzlehttp/promises/src/Each.php +17 -16 18.4 → trunk View file →
@@ -1,6 +1,7 @@
1 1 <?php
2 2
3 +declare (strict_types=1);
3 4 namespace YoastSEO_Vendor\GuzzleHttp\Promise;
4 5
5 6 final class Each
6 7 {
@@ -16,16 +17,13 @@
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) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
27 24 {
25 + $iterable = self::prepareIterable($iterable, __FUNCTION__);
28 26 return (new \YoastSEO_Vendor\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected]))->promise();
29 27 }
30 28 /**
31 29 * Like of, but only allows a certain number of outstanding promises at any
@@ -36,15 +34,12 @@
36 34 * for dynamic a concurrency size.
37 35 *
38 36 * @param mixed $iterable
39 37 * @param int|callable $concurrency
40 - * @param callable $onFulfilled
41 - * @param callable $onRejected
42 - *
43 - * @return PromiseInterface
44 38 */
45 - public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
39 + public static function ofLimit($iterable, $concurrency, ?callable $onFulfilled = null, ?callable $onRejected = null) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
46 40 {
41 + $iterable = self::prepareIterable($iterable, __FUNCTION__);
47 42 return (new \YoastSEO_Vendor\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected, 'concurrency' => $concurrency]))->promise();
48 43 }
49 44 /**
50 45 * Like limit, but ensures that no promise in the given $iterable argument
@@ -52,15 +47,21 @@
52 47 * rejected with the encountered rejection.
53 48 *
54 49 * @param mixed $iterable
55 50 * @param int|callable $concurrency
56 - * @param callable $onFulfilled
57 - *
58 - * @return PromiseInterface
59 51 */
60 - public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null)
52 + public static function ofLimitAll($iterable, $concurrency, ?callable $onFulfilled = null) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
61 53 {
62 - return each_limit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface $aggregate) {
54 + $iterable = self::prepareIterable($iterable, __FUNCTION__);
55 + return self::ofLimit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface $aggregate) : void {
63 56 $aggregate->reject($reason);
64 57 });
58 + }
59 + private static function prepareIterable($iterable, string $method) : iterable
60 + {
61 + if (\is_iterable($iterable)) {
62 + return $iterable;
63 + }
64 + \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/promises', '2.5', 'Passing a non-iterable to %s::%s() is deprecated; guzzlehttp/promises 3.0 will require an iterable.', self::class, $method);
65 + return [$iterable];
65 66 }
66 67 }