Skip to content

Commit a55d386

Browse files
committed
Allow implementations to return values by leaving it unspecified, revert callable docs
1 parent 1c4c2d9 commit a55d386

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,18 @@ interface Promise
5656
*
5757
* If the promise is already resolved, the callback MUST be executed immediately.
5858
*
59-
* @param callable(mixed $reason, mixed $value) @onResolved `$reason` shall be `null` on success, `$value` shall be
60-
* `null` on failure.
59+
* @param callable(\Throwable|\Exception|null $exception, mixed $value) @onResolved `$reason` shall be `null` on
60+
* success, `$value` shall be `null` on failure.
6161
*
62-
* @return void
62+
* @return mixed Return type and value are unspecified.
6363
*/
6464
public function when(callable $onResolved);
6565
}
6666
```
6767

68-
The implementation MAY extend `Promise::when()` with additional parameters passed to the callback. Further arguments to `Promise::when()` MUST have default values, so `Promise::when()` can always be called with only one argument. `Promise::when()` MAY NOT return a value. `Promise::when()` MUST NOT throw exceptions bubbling up from a callback invocation.
69-
7068
All callbacks registered before the `Promise` is resolved MUST be executed in the order they were registered after the `Promise` has been resolved. Callbacks registered after the resolution MUST be executed immediately.
7169

72-
If one of the callbacks throws an `Exception` or `Throwable`, it MUST be forwarded to `AsyncInterop\Promise\ErrorHandler::notify`. The `Promise` implementation MUST then continue to call the remaining callbacks with the original parameters.
70+
The invocation of `Promise::when()` MUST NOT throw exceptions bubbling up from a `$onResolved` invocation. If one of the callbacks throws an `Exception` or `Throwable`, it MUST be forwarded to `AsyncInterop\Promise\ErrorHandler::notify`. The `Promise` implementation MUST then continue to call the remaining callbacks with the original parameters.
7371

7472
Registered callbacks MUST NOT be called from a file with strict types enabled (`declare(strict_types=1)`).
7573

src/Promise.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ interface Promise
1212
*
1313
* If the promise is already resolved, the callback MUST be executed immediately.
1414
*
15-
* @param callable(mixed $reason, mixed $value) @onResolved `$reason` shall be `null` on success, `$value` shall be
16-
* `null` on failure.
15+
* @param callable(\Throwable|\Exception|null $exception, mixed $value) @onResolved `$reason` shall be `null` on
16+
* success, `$value` shall be `null` on failure.
1717
*
18-
* @return void
18+
* @return mixed Return type and value are unspecified.
1919
*/
2020
public function when(callable $onResolved);
21-
}
21+
}

0 commit comments

Comments
 (0)