promisor = $promisor; } /** * {@inheritdoc} */ public function when(callable $onResolved) { if ($this->promise === null) { $provider = $this->promisor; $this->promisor = null; try { $this->promise = $provider(); if ($this->promise instanceof ReactPromise) { $this->promise = adapt($this->promise); } if (!$this->promise instanceof Promise) { $this->promise = new Success($this->promise); } } catch (\Throwable $exception) { $this->promise = new Failure($exception); } } $this->promise->when($onResolved); } }