YoastSEO_Vendor\GuzzleHttp\Promise
Promise::settle() private Yoast 1.0
{} Это метод класса: Promise{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
// private - только в коде основоного (родительского) класса $result = $this->settle( $state, $value );
Код Promise::settle() Promise::settle Yoast 15.6.2
private function settle($state, $value)
{
if ($this->state !== self::PENDING) {
// Ignore calls with the same resolution.
if ($state === $this->state && $value === $this->result) {
return;
}
throw $this->state === $state ? new \LogicException("The promise is already {$state}.") : new \LogicException("Cannot change a {$this->state} promise to {$state}");
}
if ($value === $this) {
throw new \LogicException('Cannot fulfill or reject a promise with itself');
}
// Clear out the state of the promise but stash the handlers.
$this->state = $state;
$this->result = $value;
$handlers = $this->handlers;
$this->handlers = null;
$this->waitList = $this->waitFn = null;
$this->cancelFn = null;
if (!$handlers) {
return;
}
// If the value was not a settled promise or a thenable, then resolve
// it in the task queue using the correct ID.
if (!\method_exists($value, 'then')) {
$id = $state === self::FULFILLED ? 1 : 2;
// It's a success, so resolve the handlers in the queue.
queue()->add(static function () use($id, $value, $handlers) {
foreach ($handlers as $handler) {
self::callHandler($id, $value, $handler);
}
});
} elseif ($value instanceof \YoastSEO_Vendor\GuzzleHttp\Promise\Promise && $value->getState() === self::PENDING) {
// We can just merge our handlers onto the next promise.
$value->handlers = \array_merge($value->handlers, $handlers);
} else {
// Resolve the handlers when the forwarded promise is resolved.
$value->then(static function ($value) use($handlers) {
foreach ($handlers as $handler) {
self::callHandler(1, $value, $handler);
}
}, static function ($reason) use($handlers) {
foreach ($handlers as $handler) {
self::callHandler(2, $reason, $handler);
}
});
}
}