13
13
*
14
14
* If `$promiseOrValue` is a promise, it will be returned as is.
15
15
*
16
- * @param mixed $promiseOrValue
17
- * @return PromiseInterface
16
+ * @template-covariant T
17
+ * @template TFulfilled as PromiseInterface<T>|T
18
+ * @param TFulfilled $promiseOrValue
19
+ * @return (TFulfilled is PromiseInterface ? TFulfilled : PromiseInterface<TFulfilled>)
18
20
*/
19
21
function resolve ($ promiseOrValue = null )
20
22
{
@@ -52,8 +54,10 @@ function resolve($promiseOrValue = null)
52
54
* throwing an exception. For example, it allows you to propagate a rejection with
53
55
* the value of another promise.
54
56
*
55
- * @param mixed $promiseOrValue
56
- * @return PromiseInterface
57
+ * @template T is null
58
+ * @template R
59
+ * @param R $promiseOrValue
60
+ * @return PromiseInterface<T>
57
61
*/
58
62
function reject ($ promiseOrValue = null )
59
63
{
@@ -72,8 +76,9 @@ function reject($promiseOrValue = null)
72
76
* will be an array containing the resolution values of each of the items in
73
77
* `$promisesOrValues`.
74
78
*
75
- * @param array $promisesOrValues
76
- * @return PromiseInterface
79
+ * @template T
80
+ * @param array<PromiseInterface<T>|T> $promisesOrValues
81
+ * @return PromiseInterface<array<T>>
77
82
*/
78
83
function all ($ promisesOrValues )
79
84
{
@@ -89,8 +94,9 @@ function all($promisesOrValues)
89
94
* The returned promise will become **infinitely pending** if `$promisesOrValues`
90
95
* contains 0 items.
91
96
*
92
- * @param array $promisesOrValues
93
- * @return PromiseInterface
97
+ * @template T
98
+ * @param array<PromiseInterface<T>|T> $promisesOrValues
99
+ * @return PromiseInterface<T>
94
100
*/
95
101
function race ($ promisesOrValues )
96
102
{
@@ -126,8 +132,9 @@ function race($promisesOrValues)
126
132
* The returned promise will also reject with a `React\Promise\Exception\LengthException`
127
133
* if `$promisesOrValues` contains 0 items.
128
134
*
129
- * @param array $promisesOrValues
130
- * @return PromiseInterface
135
+ * @template T
136
+ * @param array<PromiseInterface<T>|T> $promisesOrValues
137
+ * @return PromiseInterface<T>
131
138
*/
132
139
function any ($ promisesOrValues )
133
140
{
@@ -151,9 +158,10 @@ function any($promisesOrValues)
151
158
* The returned promise will also reject with a `React\Promise\Exception\LengthException`
152
159
* if `$promisesOrValues` contains less items than `$howMany`.
153
160
*
154
- * @param array $promisesOrValues
161
+ * @template T
162
+ * @param array<PromiseInterface<T>|T> $promisesOrValues
155
163
* @param int $howMany
156
- * @return PromiseInterface
164
+ * @return PromiseInterface<array<T>>
157
165
*/
158
166
function some ($ promisesOrValues , $ howMany )
159
167
{
@@ -228,9 +236,11 @@ function some($promisesOrValues, $howMany)
228
236
* The map function receives each item as argument, where item is a fully resolved
229
237
* value of a promise or value in `$promisesOrValues`.
230
238
*
231
- * @param array $promisesOrValues
232
- * @param callable $mapFunc
233
- * @return PromiseInterface
239
+ * @template-covariant T
240
+ * @template TFulfilled as PromiseInterface<T>|T
241
+ * @param array<PromiseInterface<T>|T> $promisesOrValues
242
+ * @param callable(T): TFulfilled $mapFunc
243
+ * @return PromiseInterface<array<T>>
234
244
*/
235
245
function map ($ promisesOrValues , callable $ mapFunc )
236
246
{
@@ -276,10 +286,11 @@ function ($mapped) use ($i, &$values, &$toResolve, $resolve) {
276
286
* promise, *and* `$initialValue` may be a promise or a value for the starting
277
287
* value.
278
288
*
279
- * @param array $promisesOrValues
280
- * @param callable $reduceFunc
289
+ * @template T
290
+ * @param array<PromiseInterface<T>|T> $promisesOrValues
291
+ * @param callable(T): bool $reduceFunc
281
292
* @param mixed $initialValue
282
- * @return PromiseInterface
293
+ * @return PromiseInterface<array<T>>
283
294
*/
284
295
function reduce ($ promisesOrValues , callable $ reduceFunc , $ initialValue = null )
285
296
{
0 commit comments