Skip to content

Commit 189f4c2

Browse files
authored
Fix example with iterable
The old example throws this error; `PHP Fatal error: Uncaught TypeError: Argument 1 passed to Symfony\Component\Console\Helper\ProgressBar::iterate() must be iterable, object given`
1 parent 0963219 commit 189f4c2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

components/console/helpers/progressbar.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ which starts, advances and finishes the progress bar automatically::
105105

106106
$progressBar = new ProgressBar($output);
107107

108-
// $iterable can be for example an array ([1, 2, 3, ...]) or a generator
109-
// $iterable = function () { yield 1; yield 2; ... };
110-
foreach ($progressBar->iterate($iterable) as $value) {
108+
// $iterable can be for example an array ([1, 2, 3, ...])
109+
foreach ($progressBar->iterate([1, 2, 3]) as $value) {
110+
// ... do some work
111+
}
112+
// or a generator
113+
// function iterable() { yield 1; yield 2; ... };
114+
foreach ($progressBar->iterate(iterable()) as $value) {
111115
// ... do some work
112116
}
113117

0 commit comments

Comments
 (0)