Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Pass iterable keys to withProgressBar in InteractsWithIO #52623

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

robinmoisson
Copy link
Contributor

@robinmoisson robinmoisson commented Sep 2, 2024

The withProgressBar method in the InteractsWithIO console trait can be used to iterate over an iterable while displaying a progress bar in the console, in essence adding a progress bar to a foreach loop.

Currently the callback only takes the $value of each step, which means it can't be used as easily if we want to unpack both $key and $value in each step.

This PR adds $key to the callback called in the foreach, transforming it from $callback($value, $bar) to $callback($value, $bar, $key), with arguments in that order to keep backward compatibility ($bar is the ProgressBar instance).


I'm not sure if it's really necessary to update the progress bar docs to show that extra parameter, but if you think it'd be better I'd be happy to.

@taylorotwell taylorotwell merged commit 13d2886 into laravel:11.x Sep 2, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants