9429face97
This PR was merged into the 4.3-dev branch.
Discussion
----------
[Console] Add an iterate method to the ProgressBar class
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/pull/10949
Add an iterate method to the `ProgressBar` class that simplify updating the progress bar when iterating over an `iterable`.
Before:
```php
$bar->start();
foreach ($iterable as $value) {
// Process $value
$bar->advance();
}
$bar->finish();
```
After:
```php
foreach ($bar->iterate($iterable) as $value) {
// Process $value
}
```
Additionally if `$iterable` is countable, the progress bar max step will automatically set to its count. If it isn't countable, nothing is done (instead of setting it to 0) to allow passing a max independently before calling `iterate`.
I will try to do the doc PR soon.
Commits
-------
|
||
---|---|---|
.. | ||
Command | ||
CommandLoader | ||
DependencyInjection | ||
Descriptor | ||
Event | ||
EventListener | ||
Exception | ||
Formatter | ||
Helper | ||
Input | ||
Logger | ||
Output | ||
Question | ||
Resources/bin | ||
Style | ||
Tester | ||
Tests | ||
.gitignore | ||
Application.php | ||
CHANGELOG.md | ||
composer.json | ||
ConsoleEvents.php | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
Terminal.php |
Console Component
The Console component eases the creation of beautiful and testable command line interfaces.
Resources
Credits
Resources/bin/hiddeninput.exe
is a third party binary provided within this
component. Find sources and license at https://github.com/Seldaek/hidden-input.