Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ProgressBar.php

function ProgressBar::iterate

Returns an iterator that will automatically update the progress bar when iterated.

@template TKey @template TValue

Parameters

iterable<TKey, TValue> $iterable:

int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable:

Return value

iterable<TKey, TValue>

File

vendor/symfony/console/Helper/ProgressBar.php, line 316

Class

ProgressBar
The ProgressBar provides helpers to display progress output.

Namespace

Symfony\Component\Console\Helper

Code

public function iterate(iterable $iterable, ?int $max = null) : iterable {
    if (0 === $max) {
        $max = null;
    }
    $max ??= is_countable($iterable) ? \count($iterable) : null;
    if (0 === $max) {
        $this->max = 0;
        $this->stepWidth = 2;
        $this->finish();
        return;
    }
    $this->start($max);
    foreach ($iterable as $key => $value) {
        (yield $key => $value);
        $this->advance();
    }
    $this->finish();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal