← All changes
|
includes/sdk/google/guzzlehttp/guzzle/src/Pool.php
+16
-16
1.2.2
→
1.4.2
View file →
| @@ -1,13 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace Dudlewebs\WPMCS\GuzzleHttp; | |
| 3 | +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp; | |
| 4 | 4 | |
| 5 | -use Dudlewebs\WPMCS\GuzzleHttp\Promise as P; | |
| 6 | -use Dudlewebs\WPMCS\GuzzleHttp\Promise\EachPromise; | |
| 7 | -use Dudlewebs\WPMCS\GuzzleHttp\Promise\PromiseInterface; | |
| 8 | -use Dudlewebs\WPMCS\GuzzleHttp\Promise\PromisorInterface; | |
| 9 | -use Dudlewebs\WPMCS\Psr\Http\Message\RequestInterface; | |
| 5 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise as P; | |
| 6 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise\EachPromise; | |
| 7 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise\PromiseInterface; | |
| 8 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise\PromisorInterface; | |
| 9 | +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\RequestInterface; | |
| 10 | 10 | /** |
| 11 | 11 | * Sends an iterator of requests concurrently using a capped pool size. |
| 12 | 12 | * |
| 13 | 13 | * The pool will read from an iterator until it is cancelled or until the |
| @@ -47,16 +47,16 @@ | ||
| 47 | 47 | } else { |
| 48 | 48 | $opts = []; |
| 49 | 49 | } |
| 50 | 50 | $iterable = P\Create::iterFor($requests); |
| 51 | - $requests = static function () use ($iterable, $client, $opts) { | |
| 51 | + $requests = static function () use($iterable, $client, $opts) { | |
| 52 | 52 | foreach ($iterable as $key => $rfn) { |
| 53 | 53 | if ($rfn instanceof RequestInterface) { |
| 54 | - yield $key => $client->sendAsync($rfn, $opts); | |
| 54 | + (yield $key => $client->sendAsync($rfn, $opts)); | |
| 55 | 55 | } elseif (\is_callable($rfn)) { |
| 56 | - yield $key => $rfn($opts); | |
| 56 | + (yield $key => $rfn($opts)); | |
| 57 | 57 | } else { |
| 58 | - throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7\Http\Message\RequestInterface or a callable that returns a promise that fulfills with a Psr7\Message\Http\ResponseInterface object.'); | |
| 58 | + throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7\\Http\\Message\\RequestInterface or a callable that returns a promise that fulfills with a Psr7\\Message\\Http\\ResponseInterface object.'); | |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | }; |
| 62 | 62 | $this->each = new EachPromise($requests(), $config); |
| @@ -63,9 +63,9 @@ | ||
| 63 | 63 | } |
| 64 | 64 | /** |
| 65 | 65 | * Get promise |
| 66 | 66 | */ |
| 67 | - public function promise(): PromiseInterface | |
| 67 | + public function promise() : PromiseInterface | |
| 68 | 68 | { |
| 69 | 69 | return $this->each->promise(); |
| 70 | 70 | } |
| 71 | 71 | /** |
| @@ -78,9 +78,9 @@ | ||
| 78 | 78 | * |
| 79 | 79 | * @param ClientInterface $client Client used to send the requests |
| 80 | 80 | * @param array|\Iterator $requests Requests to send concurrently. |
| 81 | 81 | * @param array $options Passes through the options available in |
| 82 | - * {@see \GuzzleHttp\Pool::__construct} | |
| 82 | + * {@see Pool::__construct} | |
| 83 | 83 | * |
| 84 | 84 | * @return array Returns an array containing the response or an exception |
| 85 | 85 | * in the same order that the requests were sent. |
| 86 | 86 | * |
| @@ -85,9 +85,9 @@ | ||
| 85 | 85 | * in the same order that the requests were sent. |
| 86 | 86 | * |
| 87 | 87 | * @throws \InvalidArgumentException if the event format is incorrect. |
| 88 | 88 | */ |
| 89 | - public static function batch(ClientInterface $client, $requests, array $options = []): array | |
| 89 | + public static function batch(ClientInterface $client, $requests, array $options = []) : array | |
| 90 | 90 | { |
| 91 | 91 | $res = []; |
| 92 | 92 | self::cmpCallback($options, 'fulfilled', $res); |
| 93 | 93 | self::cmpCallback($options, 'rejected', $res); |
| @@ -98,17 +98,17 @@ | ||
| 98 | 98 | } |
| 99 | 99 | /** |
| 100 | 100 | * Execute callback(s) |
| 101 | 101 | */ |
| 102 | - private static function cmpCallback(array &$options, string $name, array &$results): void | |
| 102 | + private static function cmpCallback(array &$options, string $name, array &$results) : void | |
| 103 | 103 | { |
| 104 | 104 | if (!isset($options[$name])) { |
| 105 | - $options[$name] = static function ($v, $k) use (&$results) { | |
| 105 | + $options[$name] = static function ($v, $k) use(&$results) { | |
| 106 | 106 | $results[$k] = $v; |
| 107 | 107 | }; |
| 108 | 108 | } else { |
| 109 | 109 | $currentFn = $options[$name]; |
| 110 | - $options[$name] = static function ($v, $k) use (&$results, $currentFn) { | |
| 110 | + $options[$name] = static function ($v, $k) use(&$results, $currentFn) { | |
| 111 | 111 | $currentFn($v, $k); |
| 112 | 112 | $results[$k] = $v; |
| 113 | 113 | }; |
| 114 | 114 | } |