12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace React\Promise;
- class SimpleTestCancellableThenable
- {
- /** @var bool */
- public $cancelCalled = false;
- /** @var ?callable */
- public $onCancel;
- public function __construct(callable $onCancel = null)
- {
- $this->onCancel = $onCancel;
- }
- public function then(callable $onFulfilled = null, callable $onRejected = null): self
- {
- return new self();
- }
- public function cancel(): void
- {
- $this->cancelCalled = true;
- if (is_callable($this->onCancel)) {
- ($this->onCancel)();
- }
- }
- }
|