function Utils::inspect
Synchronously waits on a promise to resolve and returns an inspection state array.
Returns a state associative array containing a "state" key mapping to a valid promise state. If the state of the promise is "fulfilled", the array will contain a "value" key mapping to the fulfilled value of the promise. If the promise is rejected, the array will contain a "reason" key mapping to the rejection reason of the promise.
Parameters
PromiseInterface $promise Promise or value.:
1 call to Utils::inspect()
- Utils::inspectAll in vendor/
guzzlehttp/ promises/ src/ Utils.php - Waits on all of the provided promises, but does not unwrap rejected promises as thrown exception.
File
-
vendor/
guzzlehttp/ promises/ src/ Utils.php, line 72
Class
Namespace
GuzzleHttp\PromiseCode
public static function inspect(PromiseInterface $promise) : array {
try {
return [
'state' => PromiseInterface::FULFILLED,
'value' => $promise->wait(),
];
} catch (RejectionException $e) {
return [
'state' => PromiseInterface::REJECTED,
'reason' => $e->getReason(),
];
} catch (\Throwable $e) {
return [
'state' => PromiseInterface::REJECTED,
'reason' => $e,
];
}
}