1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
<?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)();
}
}
}
|