Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\Adapter
SyncPromise::resolve
Method of the class: SyncPromise{}
No Hooks.
Returns
null. Nothing (null).
Usage
$SyncPromise = new SyncPromise(); $SyncPromise->resolve( $value ): self;
- $value(mixed) (required)
- .
SyncPromise::resolve() SyncPromise::resolve code WC 11.0.1
public function resolve($value): self
{
switch ($this->state) {
case self::PENDING:
if ($value === $this) {
throw new \Exception('Cannot resolve promise with self.');
}
if (is_object($value) && method_exists($value, 'then')) {
$value->then(
function ($resolvedValue): void {
$this->resolve($resolvedValue);
},
function (\Throwable $reason): void {
$this->reject($reason);
}
);
return $this;
}
$this->state = self::FULFILLED;
$this->result = $value;
$this->enqueueWaitingPromises();
break;
case self::FULFILLED:
if ($this->result !== $value) {
throw new \Exception('Cannot change value of fulfilled promise.');
}
break;
case self::REJECTED:
throw new \Exception('Cannot resolve rejected promise.');
}
return $this;
}