Skip to content

Commit 604ef4c

Browse files
committed
Clarify Promise::when docblock
It specifies the exact invocation parameter values now and includes a statement about always-sync when callbacks. Closes #20.
1 parent 8c50edd commit 604ef4c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Promise.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ interface Promise
1010
/**
1111
* Registers a callback to be invoked when the promise is resolved.
1212
*
13-
* @param callable(\Throwable|\Exception|null $exception, mixed $result) $onResolved
13+
* The callback receives `null` as first parameter and `$value` as second parameter on success. It receives the
14+
* failure reason as first parameter and `null` as second parameter on failure.
15+
*
16+
* If the promise is already resolved, the callback MUST be executed immediately.
17+
*
18+
* Warning: If you use type declarations for `$value`, be sure to make them accept `null` in case of failures.
19+
*
20+
* @param callable(\Throwable|\Exception|null $exception, mixed $value) $onResolved Callback to be executed.
1421
*
1522
* @return void
1623
*/

0 commit comments

Comments
 (0)