SimpleTestCancellableThenable.php 588 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace React\Promise;
  3. class SimpleTestCancellableThenable
  4. {
  5. /** @var bool */
  6. public $cancelCalled = false;
  7. /** @var ?callable */
  8. public $onCancel;
  9. public function __construct(callable $onCancel = null)
  10. {
  11. $this->onCancel = $onCancel;
  12. }
  13. public function then(callable $onFulfilled = null, callable $onRejected = null): self
  14. {
  15. return new self();
  16. }
  17. public function cancel(): void
  18. {
  19. $this->cancelCalled = true;
  20. if (is_callable($this->onCancel)) {
  21. ($this->onCancel)();
  22. }
  23. }
  24. }