You are here

function some in Zircon Profile 8

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

Initiate a competitive race between multiple promises or values (values will become immediately fulfilled promises).

When count amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.

This prommise is rejected with a {if the number of fulfilled promises is less than the desired $count.

Parameters

int $count Total number of promises.:

mixed $promises Promises or values.:

Return value

Promise

See also

GuzzleHttp\Promise\AggregateException}

44 string references to 'some'
CategorizingPluginManagerTraitTest::testProcessDefinitionCategory in core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php
@covers ::processDefinitionCategory
d6_system_logging.yml in core/modules/system/migration_templates/d6_system_logging.yml
core/modules/system/migration_templates/d6_system_logging.yml
DisplayPluginBase::defineOptions in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Information about options for all kinds of purposes will be held here.
DisplayTest::testReadMore in core/modules/views/src/Tests/Plugin/DisplayTest.php
Tests the readmore functionality.
MigrateSystemLoggingTest::testSystemLogging in core/modules/system/src/Tests/Migrate/d6/MigrateSystemLoggingTest.php
Tests migration of system error_level variables to system.logging.yml.

... See full list

File

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

Namespace

GuzzleHttp\Promise

Code

function some($count, $promises) {
  $results = [];
  $rejections = [];
  return each($promises, function ($value, $idx, PromiseInterface $p) use (&$results, $count) {
    if ($p
      ->getState() !== PromiseInterface::PENDING) {
      return;
    }
    $results[$idx] = $value;
    if (count($results) >= $count) {
      $p
        ->resolve(null);
    }
  }, function ($reason) use (&$rejections) {
    $rejections[] = $reason;
  })
    ->then(function () use (&$results, &$rejections, $count) {
    if (count($results) !== $count) {
      throw new AggregateException('Not enough promises to fulfill count', $rejections);
    }
    ksort($results);
    return array_values($results);
  });
}