File tree Expand file tree Collapse file tree 4 files changed +796
-6
lines changed Expand file tree Collapse file tree 4 files changed +796
-6
lines changed Original file line number Diff line number Diff line change @@ -201,9 +201,9 @@ public function any(array $promises): PromiseInterface
201
201
202
202
/**
203
203
* @param callable(): PromiseInterface<mixed>|PromiseInterface<mixed>|array<int|string, callable(): PromiseInterface<mixed>|PromiseInterface<mixed>> $promises
204
- * @return PromiseInterface <mixed>
204
+ * @return CancellablePromiseInterface <mixed>
205
205
*/
206
- public function timeout (callable |PromiseInterface |array $ promises , float $ seconds ): PromiseInterface
206
+ public function timeout (callable |PromiseInterface |array $ promises , float $ seconds ): CancellablePromiseInterface
207
207
{
208
208
return $ this ->collectionHandler ->timeout ($ promises , $ seconds );
209
209
}
Original file line number Diff line number Diff line change 5
5
use Exception ;
6
6
use InvalidArgumentException ;
7
7
use Rcalicdan \FiberAsync \Promise \CancellablePromise ;
8
+ use Rcalicdan \FiberAsync \Promise \Interfaces \CancellablePromiseInterface ;
8
9
use Rcalicdan \FiberAsync \Promise \Interfaces \PromiseInterface ;
9
10
use Rcalicdan \FiberAsync \Promise \Promise ;
10
11
use RuntimeException ;
@@ -162,7 +163,7 @@ public function race(array $promises): PromiseInterface
162
163
public function timeout (
163
164
callable |PromiseInterface |array $ operations ,
164
165
float $ seconds
165
- ): PromiseInterface {
166
+ ): CancellablePromiseInterface {
166
167
if ($ seconds <= 0 ) {
167
168
throw new InvalidArgumentException ('Timeout must be greater than zero ' );
168
169
}
@@ -180,7 +181,7 @@ public function timeout(
180
181
->then (fn () => throw new Exception ("Operation timed out after {$ seconds } seconds " ))
181
182
;
182
183
183
- /** @var array<int|string, callable(): PromiseInterface <mixed>|PromiseInterface <mixed>> $racePromises */
184
+ /** @var array<int|string, callable(): CancellablePromiseInterface <mixed>|CancellablePromiseInterface <mixed>> $racePromises */
184
185
$ racePromises = [...$ promises , $ timeoutPromise ];
185
186
186
187
return $ this ->race ($ racePromises );
Original file line number Diff line number Diff line change @@ -164,9 +164,9 @@ function any(array $promises): PromiseInterface
164
164
*
165
165
* @param callable|PromiseInterface<mixed>|array<PromiseInterface<mixed>> $promises Number of seconds to wait before resolving
166
166
* @param float $seconds Number of seconds to wait before resolving
167
- * @return PromiseInterface <mixed> A promise that resolves after the delay
167
+ * @return CancellablePromiseInterface <mixed> A promise that resolves after the delay
168
168
*/
169
- function timeout (callable |PromiseInterface |array $ promises , float $ seconds ): PromiseInterface
169
+ function timeout (callable |PromiseInterface |array $ promises , float $ seconds ): CancellablePromiseInterface
170
170
{
171
171
return Promise::timeout ($ promises , $ seconds );
172
172
}
You can’t perform that action at this time.
0 commit comments