[11.x] Pass iterable keys to withProgressBar
in InteractsWithIO
#52623
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
withProgressBar
method in theInteractsWithIO
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 aforeach
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 theforeach
, 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.