You are here

function all in Lockr 7.3

Given an array of promises, return a promise that is fulfilled when all the items in the array are fulfilled.

The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.

Parameters

mixed $promises Promises or values.:

Return value

PromiseInterface

File

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

Namespace

GuzzleHttp\Promise

Code

function all($promises) {
  $results = [];
  return each($promises, function ($value, $idx) use (&$results) {
    $results[$idx] = $value;
  }, function ($reason, $idx, Promise $aggregate) {
    $aggregate
      ->reject($reason);
  })
    ->then(function () use (&$results) {
    ksort($results);
    return $results;
  });
}