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\HelperCode
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();
}