|
18 | 18 | * is reached, it will not start a new operation and instead queue this for future |
19 | 19 | * execution. Once one of the pending operations complete, it will pick the next |
20 | 20 | * job from the queue and execute this operation. |
| 21 | + * |
| 22 | + * @template T |
21 | 23 | */ |
22 | 24 | class Queue implements \Countable |
23 | 25 | { |
@@ -100,10 +102,13 @@ class Queue implements \Countable |
100 | 102 | * > Keep in mind that returning an array of response messages means that |
101 | 103 | * the whole response body has to be kept in memory. |
102 | 104 | * |
103 | | - * @param int $concurrency concurrency soft limit |
104 | | - * @param array $jobs |
105 | | - * @param callable $handler |
106 | | - * @return PromiseInterface Returns a Promise<mixed[]> which resolves with an array of all resolution values |
| 105 | + * @template TKey |
| 106 | + * @template TIn |
| 107 | + * @template TOut |
| 108 | + * @param int $concurrency concurrency soft limit |
| 109 | + * @param array<TKey,TIn> $jobs |
| 110 | + * @param callable(TIn):PromiseInterface<TOut> $handler |
| 111 | + * @return PromiseInterface<array<TKey,TOut>> Returns a Promise which resolves with an array of all resolution values |
107 | 112 | * or rejects when any of the operations reject. |
108 | 113 | */ |
109 | 114 | public static function all($concurrency, array $jobs, $handler) |
@@ -212,10 +217,13 @@ public static function all($concurrency, array $jobs, $handler) |
212 | 217 | * $promise = Queue::any(10, $jobs, array($browser, 'get')); |
213 | 218 | * ``` |
214 | 219 | * |
215 | | - * @param int $concurrency concurrency soft limit |
216 | | - * @param array $jobs |
217 | | - * @param callable $handler |
218 | | - * @return PromiseInterface Returns a Promise<mixed> which resolves with a single resolution value |
| 220 | + * @template TKey |
| 221 | + * @template TIn |
| 222 | + * @template TOut |
| 223 | + * @param int $concurrency concurrency soft limit |
| 224 | + * @param array<TKey,TIn> $jobs |
| 225 | + * @param callable(TIn):PromiseInterface<TOut> $handler |
| 226 | + * @return PromiseInterface<TOut> Returns a Promise which resolves with a single resolution value |
219 | 227 | * or rejects when all of the operations reject. |
220 | 228 | */ |
221 | 229 | public static function any($concurrency, array $jobs, $handler) |
@@ -307,9 +315,9 @@ public static function any($concurrency, array $jobs, $handler) |
307 | 315 | * $q = new Queue(10, null, array($browser, 'get')); |
308 | 316 | * ``` |
309 | 317 | * |
310 | | - * @param int $concurrency concurrency soft limit |
311 | | - * @param int|null $limit queue hard limit or NULL=unlimited |
312 | | - * @param callable $handler |
| 318 | + * @param int $concurrency concurrency soft limit |
| 319 | + * @param int|null $limit queue hard limit or NULL=unlimited |
| 320 | + * @param callable(mixed):PromiseInterface<T> $handler |
313 | 321 | * @throws \InvalidArgumentException |
314 | 322 | */ |
315 | 323 | public function __construct($concurrency, $limit, $handler) |
@@ -338,7 +346,7 @@ public function __construct($concurrency, $limit, $handler) |
338 | 346 | * completed. This means that this is handled entirely transparently and you do not |
339 | 347 | * need to worry about this concurrency limit yourself. |
340 | 348 | * |
341 | | - * @return \React\Promise\PromiseInterface |
| 349 | + * @return PromiseInterface<T> |
342 | 350 | */ |
343 | 351 | public function __invoke() |
344 | 352 | { |
@@ -395,6 +403,7 @@ public function count() |
395 | 403 |
|
396 | 404 | /** |
397 | 405 | * @internal |
| 406 | + * @param PromiseInterface<T> $promise |
398 | 407 | */ |
399 | 408 | public function await(PromiseInterface $promise) |
400 | 409 | { |
|
0 commit comments