-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Support iterable in SymfonyStyle::write/writeln #26863
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
[Console] Support iterable in SymfonyStyle::write/writeln #26863
Conversation
Should/Can we update |
These methods are not part of |
(I'm not convinced enabling support for iterables in |
edit:
Well we did it for |
I don't see many use cases for generators when displaying blocks, title, sections, etc... while |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with minor comment
|
||
$output->writeln('Lorem ipsum dolor sit amet'); | ||
$output->newLine(2); //Should append an extra blank line | ||
$output->title('Fifth title'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sixth :)
Thank you @ogizanagi. |
…eln (ogizanagi) This PR was merged into the 4.1-dev branch. Discussion ---------- [Console] Support iterable in SymfonyStyle::write/writeln | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Relates to #26847. This would enable iterables benefits even when using `SymfonyStyle` output. Commits ------- d66827e [Console] Support iterable in SymfonyStyle::write/writeln
{ | ||
// We need to know if the two last chars are PHP_EOL | ||
// Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer | ||
return array_map(function ($value) { | ||
return substr($value, -4); | ||
}, array_merge(array($this->bufferedOutput->fetch()), (array) $messages)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the fetch
part was useless all along?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't useless, but as we now only handle strings one by one and are writing to the buffer directly (instead of concatenating arrays of buffered output), it is not required anymore.
Nice change @ogizanagi . Thanks |
Relates to #26847.
This would enable iterables benefits even when using
SymfonyStyle
output.