You are here

function settle in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/promises/src/functions.php \GuzzleHttp\Promise\settle()

Returns a promise that is fulfilled when all of the provided promises have been fulfilled or rejected.

The returned promise is fulfilled with an array of inspection state arrays.

Parameters

mixed $promises Promises or values.:

Return value

Promise

See also

GuzzleHttp\Promise\inspect for the inspection state array format.

File

vendor/guzzlehttp/promises/src/functions.php, line 300

Namespace

GuzzleHttp\Promise

Code

function settle($promises) {
  $results = [];
  return each($promises, function ($value, $idx) use (&$results) {
    $results[$idx] = [
      'state' => 'fulfilled',
      'value' => $value,
    ];
  }, function ($reason, $idx) use (&$results) {
    $results[$idx] = [
      'state' => 'rejected',
      'reason' => $reason,
    ];
  })
    ->then(function () use (&$results) {
    ksort($results);
    return $results;
  });
}