@@ -94,7 +94,7 @@ $deferred = new React\Promise\Deferred();
9494$promise = $deferred->promise();
9595
9696$deferred->resolve(mixed $value = null);
97- $deferred->reject(mixed $reason = null );
97+ $deferred->reject(\Throwable|\Exception $reason);
9898```
9999
100100The ` promise ` method returns the promise of the deferred.
@@ -129,17 +129,14 @@ this promise once it is resolved.
129129#### Deferred::reject()
130130
131131``` php
132- $deferred->reject(mixed $reason = null );
132+ $deferred->reject(\Throwable|\Exception $reason);
133133```
134134
135135Rejects the promise returned by ` promise() ` , signalling that the deferred's
136136computation failed.
137137All consumers are notified by having ` $onRejected ` (which they registered via
138138` $promise->then() ` ) called with ` $reason ` .
139139
140- If ` $reason ` itself is a promise, the promise will be rejected with the outcome
141- of this promise regardless whether it fulfills or rejects.
142-
143140### PromiseInterface
144141
145142The promise interface provides the common interface for all promise
@@ -358,8 +355,7 @@ Creates a already rejected promise.
358355$promise = React\Promise\RejectedPromise($reason);
359356```
360357
361- Note, that ` $reason ` ** cannot** be a promise. It's recommended to use
362- [ reject()] ( #reject ) for creating rejected promises.
358+ Note, that ` $reason ` ** must** be a ` \Throwable ` or ` \Exception ` .
363359
364360### LazyPromise
365361
@@ -410,20 +406,10 @@ If `$promiseOrValue` is a promise, it will be returned as is.
410406#### reject()
411407
412408``` php
413- $promise = React\Promise\reject(mixed $promiseOrValue );
409+ $promise = React\Promise\reject(\Throwable|\Exception $reason );
414410```
415411
416- Creates a rejected promise for the supplied ` $promiseOrValue ` .
417-
418- If ` $promiseOrValue ` is a value, it will be the rejection value of the
419- returned promise.
420-
421- If ` $promiseOrValue ` is a promise, its completion value will be the rejected
422- value of the returned promise.
423-
424- This can be useful in situations where you need to reject a promise without
425- throwing an exception. For example, it allows you to propagate a rejection with
426- the value of another promise.
412+ Creates a rejected promise for the supplied ` $reason ` .
427413
428414#### all()
429415
@@ -523,7 +509,7 @@ function getAwesomeResultPromise()
523509 $deferred = new React\Promise\Deferred();
524510
525511 // Execute a Node.js-style function using the callback pattern
526- computeAwesomeResultAsynchronously(function ($error, $result) use ($deferred) {
512+ computeAwesomeResultAsynchronously(function (\Exception $error, $result) use ($deferred) {
527513 if ($error) {
528514 $deferred->reject($error);
529515 } else {
@@ -540,7 +526,7 @@ getAwesomeResultPromise()
540526 function ($value) {
541527 // Deferred resolved, do something with $value
542528 },
543- function ($reason) {
529+ function (\Exception $reason) {
544530 // Deferred rejected, do something with $reason
545531 }
546532 );
0 commit comments