Skip to content

Commit aac5cf6

Browse files
committed
Minor reword
1 parent 1b77af8 commit aac5cf6

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

components/console/helpers/progressbar.rst

+16-6
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,32 @@ that the progress bar display is refreshed with a 100% completion.
9595
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::display`
9696
to show the progress bar again.
9797

98-
If you want to use the progress bar to show the progress of an iteration you can use the
99-
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::iterate` method that will automatically call ``start``,
100-
``advance`` and ``finish`` while iterating::
98+
If the progress information is stored in an iterable variable (such as an array
99+
or a PHP generator) you can use the
100+
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::iterate` method,
101+
which starts, advances and finishes the progress bar automatically::
101102

102103
use Symfony\Component\Console\Helper\ProgressBar;
103104

104105
$progressBar = new ProgressBar($output);
105106

106-
// starts and displays the progress bar
107-
foreach ($progressBar->iterate($iterable) as $key => $value) {
107+
// $iterable can be for example an array ([1, 2, 3, ...]) or a generator
108+
// $iterable = function () { yield 1; yield 2; ... };
109+
foreach ($progressBar->iterate($iterable) as $value) {
108110
// ... do some work
109111
}
110112

113+
If ``$iterable = [1, 2]``, the previous code will output the following:
114+
115+
.. code-block:: terminal
116+
117+
0/2 [>---------------------------] 0%
118+
1/2 [==============>-------------] 50%
119+
2/2 [============================] 100%
120+
111121
.. versionadded:: 4.3
112122

113-
The ``iterate`` method was introduced in Symfony 4.3.
123+
The ``iterate()`` method was introduced in Symfony 4.3.
114124

115125
Customizing the Progress Bar
116126
----------------------------

0 commit comments

Comments
 (0)