Skip to content

Commit b9469d3

Browse files
committed
Deprecate resolve() and reject() functions in favor of sleep()
1 parent bc185b8 commit b9469d3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ A trivial implementation of timeouts for `Promise`s, built on top of [ReactPHP](
99
* [Usage](#usage)
1010
* [timeout()](#timeout)
1111
* [sleep()](#sleep)
12-
* [resolve()](#resolve)
13-
* [reject()](#reject)
12+
* [~~resolve()~~](#resolve)
13+
* [~~reject()~~](#reject)
1414
* [TimeoutException](#timeoutexception)
1515
* [getTimeout()](#gettimeout)
1616
* [Install](#install)
@@ -204,7 +204,9 @@ $timer = React\Promise\Timer\sleep(2.0);
204204
$timer->cancel();
205205
```
206206

207-
### resolve()
207+
### ~~resolve()~~
208+
209+
> Deprecated since v1.8.0, see [`sleep()`](#sleep) instead.
208210
209211
The `resolve(float $time, ?LoopInterface $loop = null): PromiseInterface<float, RuntimeException>` function can be used to
210212
create a new promise that resolves in `$time` seconds with the `$time` as the fulfillment value.
@@ -236,7 +238,9 @@ $timer = React\Promise\Timer\resolve(2.0);
236238
$timer->cancel();
237239
```
238240

239-
### reject()
241+
### ~~reject()~~
242+
243+
> Deprecated since v1.8.0, see [`sleep()`](#sleep) instead.
240244
241245
The `reject(float $time, ?LoopInterface $loop = null): PromiseInterface<void, TimeoutException|RuntimeException>` function can be used to
242246
create a new promise which rejects in `$time` seconds with a `TimeoutException`.

src/functions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function sleep($time, LoopInterface $loop = null)
249249
}
250250

251251
/**
252-
* Create a new promise that resolves in `$time` seconds with the `$time` as the fulfillment value.
252+
* [Deprecated] Create a new promise that resolves in `$time` seconds with the `$time` as the fulfillment value.
253253
*
254254
* ```php
255255
* React\Promise\Timer\resolve(1.5)->then(function ($time) {
@@ -281,6 +281,8 @@ function sleep($time, LoopInterface $loop = null)
281281
* @param float $time
282282
* @param ?LoopInterface $loop
283283
* @return PromiseInterface<float, \RuntimeException>
284+
* @deprecated 1.8.0 See `sleep()` instead
285+
* @see sleep()
284286
*/
285287
function resolve($time, LoopInterface $loop = null)
286288
{
@@ -290,7 +292,7 @@ function resolve($time, LoopInterface $loop = null)
290292
}
291293

292294
/**
293-
* Create a new promise which rejects in `$time` seconds with a `TimeoutException`.
295+
* [Deprecated] Create a new promise which rejects in `$time` seconds with a `TimeoutException`.
294296
*
295297
* ```php
296298
* React\Promise\Timer\reject(2.0)->then(null, function (React\Promise\Timer\TimeoutException $e) {
@@ -322,6 +324,8 @@ function resolve($time, LoopInterface $loop = null)
322324
* @param float $time
323325
* @param LoopInterface $loop
324326
* @return PromiseInterface<void, TimeoutException|\RuntimeException>
327+
* @deprecated 1.8.0 See `sleep()` instead
328+
* @see sleep()
325329
*/
326330
function reject($time, LoopInterface $loop = null)
327331
{

0 commit comments

Comments
 (0)