PromiseInterface.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace React\Promise;
  3. interface PromiseInterface
  4. {
  5. /**
  6. * Transforms a promise's value by applying a function to the promise's fulfillment
  7. * or rejection value. Returns a new promise for the transformed result.
  8. *
  9. * The `then()` method registers new fulfilled and rejection handlers with a promise
  10. * (all parameters are optional):
  11. *
  12. * * `$onFulfilled` will be invoked once the promise is fulfilled and passed
  13. * the result as the first argument.
  14. * * `$onRejected` will be invoked once the promise is rejected and passed the
  15. * reason as the first argument.
  16. * * `$onProgress` (deprecated) will be invoked whenever the producer of the promise
  17. * triggers progress notifications and passed a single argument (whatever it
  18. * wants) to indicate progress.
  19. *
  20. * It returns a new promise that will fulfill with the return value of either
  21. * `$onFulfilled` or `$onRejected`, whichever is called, or will reject with
  22. * the thrown exception if either throws.
  23. *
  24. * A promise makes the following guarantees about handlers registered in
  25. * the same call to `then()`:
  26. *
  27. * 1. Only one of `$onFulfilled` or `$onRejected` will be called,
  28. * never both.
  29. * 2. `$onFulfilled` and `$onRejected` will never be called more
  30. * than once.
  31. * 3. `$onProgress` (deprecated) may be called multiple times.
  32. *
  33. * @param callable|null $onFulfilled
  34. * @param callable|null $onRejected
  35. * @param callable|null $onProgress This argument is deprecated and should not be used anymore.
  36. * @return PromiseInterface
  37. */
  38. public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null);
  39. }