@@ -97,7 +97,7 @@ $deferred = new React\Promise\Deferred();
9797$promise = $deferred->promise();
9898
9999$deferred->resolve(mixed $value = null);
100- $deferred->reject(\Throwable|\Exception $reason);
100+ $deferred->reject(\Throwable $reason);
101101```
102102
103103The ` promise ` method returns the promise of the deferred.
@@ -132,7 +132,7 @@ this promise once it is resolved.
132132#### Deferred::reject()
133133
134134``` php
135- $deferred->reject(\Throwable|\Exception $reason);
135+ $deferred->reject(\Throwable $reason);
136136```
137137
138138Rejects the promise returned by ` promise() ` , signalling that the deferred's
@@ -234,7 +234,7 @@ $promise
234234 // Only catch \RuntimeException instances
235235 // All other types of errors will propagate automatically
236236 })
237- ->otherwise(function ($reason) {
237+ ->otherwise(function (\Throwable $reason) {
238238 // Catch other errors
239239 )};
240240```
@@ -270,7 +270,7 @@ Consider the following synchronous code:
270270``` php
271271try {
272272 return doSomething();
273- } catch(\Exception $e) {
273+ } catch (\Throwable $e) {
274274 return handleError($e);
275275} finally {
276276 cleanup();
@@ -360,7 +360,7 @@ Creates a already rejected promise.
360360$promise = new React\Promise\RejectedPromise($reason);
361361```
362362
363- Note, that ` $reason ` ** must** be a ` \Throwable ` or ` \Exception ` .
363+ Note, that ` $reason ` ** must** be a ` \Throwable ` .
364364
365365### Functions
366366
@@ -390,11 +390,16 @@ If `$promiseOrValue` is a promise, it will be returned as is.
390390#### reject()
391391
392392``` php
393- $promise = React\Promise\reject(\Throwable|\Exception $reason);
393+ $promise = React\Promise\reject(\Throwable $reason);
394394```
395395
396396Creates a rejected promise for the supplied ` $reason ` .
397397
398+ Note that the [ ` \Throwable ` ] ( https://www.php.net/manual/en/class.throwable.php ) interface introduced in PHP 7 covers
399+ both user land [ ` \Exception ` ] ( https://www.php.net/manual/en/class.exception.php ) 's and
400+ [ ` \Error ` ] ( https://www.php.net/manual/en/class.error.php ) internal PHP errors. By enforcing ` \Throwable ` as reason to
401+ reject a promise, any language error or user land exception can be used to reject a promise.
402+
398403#### all()
399404
400405``` php
@@ -431,7 +436,7 @@ will be the resolution value of the triggering item.
431436The returned promise will only reject if * all* items in ` $promisesOrValues ` are
432437rejected. The rejection value will be a ` React\Promise\Exception\CompositeException `
433438which holds all rejection reasons. The rejection reasons can be obtained with
434- ` CompositeException::getExceptions () ` .
439+ ` CompositeException::getThrowables () ` .
435440
436441The returned promise will also reject with a ` React\Promise\Exception\LengthException `
437442if ` $promisesOrValues ` contains 0 items.
@@ -496,7 +501,7 @@ function getAwesomeResultPromise()
496501 $deferred = new React\Promise\Deferred();
497502
498503 // Execute a Node.js-style function using the callback pattern
499- computeAwesomeResultAsynchronously(function (\Exception $error, $result) use ($deferred) {
504+ computeAwesomeResultAsynchronously(function (\Throwable $error, $result) use ($deferred) {
500505 if ($error) {
501506 $deferred->reject($error);
502507 } else {
@@ -513,7 +518,7 @@ getAwesomeResultPromise()
513518 function ($value) {
514519 // Deferred resolved, do something with $value
515520 },
516- function (\Exception $reason) {
521+ function (\Throwable $reason) {
517522 // Deferred rejected, do something with $reason
518523 }
519524 );
0 commit comments