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