PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/guzzlehttp/promises/src/Utils.php +27 -27 1.2.12 → 1.4.2 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 declare (strict_types=1);
4 -namespace Dudlewebs\WPMCS\GuzzleHttp\Promise;
4 +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise;
5 5
6 6 final class Utils
7 7 {
8 8 /**
@@ -19,9 +19,9 @@
19 19 * </code>
20 20 *
21 21 * @param TaskQueueInterface|null $assign Optionally specify a new queue instance.
22 22 */
23 - public static function queue(?TaskQueueInterface $assign = null): TaskQueueInterface
23 + public static function queue(?TaskQueueInterface $assign = null) : TaskQueueInterface
24 24 {
25 25 static $queue;
26 26 if ($assign) {
27 27 $queue = $assign;
@@ -35,13 +35,13 @@
35 35 * returns a promise that is fulfilled or rejected with the result.
36 36 *
37 37 * @param callable $task Task function to run.
38 38 */
39 - public static function task(callable $task): PromiseInterface
39 + public static function task(callable $task) : PromiseInterface
40 40 {
41 41 $queue = self::queue();
42 42 $promise = new Promise([$queue, 'run']);
43 - $queue->add(function () use ($task, $promise): void {
43 + $queue->add(function () use($task, $promise) : void {
44 44 try {
45 45 if (Is::pending($promise)) {
46 46 $promise->resolve($task());
47 47 }
@@ -62,9 +62,9 @@
62 62 * key mapping to the rejection reason of the promise.
63 63 *
64 64 * @param PromiseInterface $promise Promise or value.
65 65 */
66 - public static function inspect(PromiseInterface $promise): array
66 + public static function inspect(PromiseInterface $promise) : array
67 67 {
68 68 try {
69 69 return ['state' => PromiseInterface::FULFILLED, 'value' => $promise->wait()];
70 70 } catch (RejectionException $e) {
@@ -82,9 +82,9 @@
82 82 * @see inspect for the inspection state array format.
83 83 *
84 84 * @param PromiseInterface[] $promises Traversable of promises to wait upon.
85 85 */
86 - public static function inspectAll($promises): array
86 + public static function inspectAll($promises) : array
87 87 {
88 88 $results = [];
89 89 foreach ($promises as $key => $promise) {
90 90 $results[$key] = self::inspect($promise);
@@ -101,9 +101,9 @@
101 101 * @param iterable<PromiseInterface> $promises Iterable of PromiseInterface objects to wait on.
102 102 *
103 103 * @throws \Throwable on error
104 104 */
105 - public static function unwrap($promises): array
105 + public static function unwrap($promises) : array
106 106 {
107 107 $results = [];
108 108 foreach ($promises as $key => $promise) {
109 109 $results[$key] = $promise->wait();
@@ -120,23 +120,23 @@
120 120 *
121 121 * @param mixed $promises Promises or values.
122 122 * @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution.
123 123 */
124 - public static function all($promises, bool $recursive = \false): PromiseInterface
124 + public static function all($promises, bool $recursive = \false) : PromiseInterface
125 125 {
126 126 $results = [];
127 - $promise = Each::of($promises, function ($value, $idx) use (&$results): void {
127 + $promise = Each::of($promises, function ($value, $idx) use(&$results) : void {
128 128 $results[$idx] = $value;
129 - }, function ($reason, $idx, Promise $aggregate): void {
129 + }, function ($reason, $idx, Promise $aggregate) : void {
130 130 if (Is::pending($aggregate)) {
131 131 $aggregate->reject($reason);
132 132 }
133 - })->then(function () use (&$results) {
134 - ksort($results);
133 + })->then(function () use(&$results) {
134 + \ksort($results);
135 135 return $results;
136 136 });
137 137 if (\true === $recursive) {
138 - $promise = $promise->then(function ($results) use ($recursive, &$promises) {
138 + $promise = $promise->then(function ($results) use($recursive, &$promises) {
139 139 foreach ($promises as $promise) {
140 140 if (Is::pending($promise)) {
141 141 return self::all($promises, $recursive);
142 142 }
@@ -159,28 +159,28 @@
159 159 *
160 160 * @param int $count Total number of promises.
161 161 * @param mixed $promises Promises or values.
162 162 */
163 - public static function some(int $count, $promises): PromiseInterface
163 + public static function some(int $count, $promises) : PromiseInterface
164 164 {
165 165 $results = [];
166 166 $rejections = [];
167 - return Each::of($promises, function ($value, $idx, PromiseInterface $p) use (&$results, $count): void {
167 + return Each::of($promises, function ($value, $idx, PromiseInterface $p) use(&$results, $count) : void {
168 168 if (Is::settled($p)) {
169 169 return;
170 170 }
171 171 $results[$idx] = $value;
172 - if (count($results) >= $count) {
172 + if (\count($results) >= $count) {
173 173 $p->resolve(null);
174 174 }
175 - }, function ($reason) use (&$rejections): void {
175 + }, function ($reason) use(&$rejections) : void {
176 176 $rejections[] = $reason;
177 - })->then(function () use (&$results, &$rejections, $count) {
178 - if (count($results) !== $count) {
177 + })->then(function () use(&$results, &$rejections, $count) {
178 + if (\count($results) !== $count) {
179 179 throw new AggregateException('Not enough promises to fulfill count', $rejections);
180 180 }
181 - ksort($results);
182 - return array_values($results);
181 + \ksort($results);
182 + return \array_values($results);
183 183 });
184 184 }
185 185 /**
186 186 * Like some(), with 1 as count. However, if the promise fulfills, the
@@ -187,9 +187,9 @@
187 187 * fulfillment value is not an array of 1 but the value directly.
188 188 *
189 189 * @param mixed $promises Promises or values.
190 190 */
191 - public static function any($promises): PromiseInterface
191 + public static function any($promises) : PromiseInterface
192 192 {
193 193 return self::some(1, $promises)->then(function ($values) {
194 194 return $values[0];
195 195 });
@@ -203,17 +203,17 @@
203 203 * @see inspect for the inspection state array format.
204 204 *
205 205 * @param mixed $promises Promises or values.
206 206 */
207 - public static function settle($promises): PromiseInterface
207 + public static function settle($promises) : PromiseInterface
208 208 {
209 209 $results = [];
210 - return Each::of($promises, function ($value, $idx) use (&$results): void {
210 + return Each::of($promises, function ($value, $idx) use(&$results) : void {
211 211 $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value];
212 - }, function ($reason, $idx) use (&$results): void {
212 + }, function ($reason, $idx) use(&$results) : void {
213 213 $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason];
214 - })->then(function () use (&$results) {
215 - ksort($results);
214 + })->then(function () use(&$results) {
215 + \ksort($results);
216 216 return $results;
217 217 });
218 218 }
219 219 }