Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #26863 [Console] Support iterable in SymfonyStyle::write/writ…
…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
- Loading branch information
Showing
3 changed files
with
82 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
.../Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_4_with_iterators.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
//Ensure has single blank line after any text and a title | ||
return function (InputInterface $input, OutputInterface $output) { | ||
$output = new SymfonyStyle($input, $output); | ||
|
||
$output->write('Lorem ipsum dolor sit amet'); | ||
$output->title('First title'); | ||
|
||
$output->writeln('Lorem ipsum dolor sit amet'); | ||
$output->title('Second title'); | ||
|
||
$output->write('Lorem ipsum dolor sit amet'); | ||
$output->write(''); | ||
$output->title('Third title'); | ||
|
||
//Ensure edge case by appending empty strings to history: | ||
$output->write('Lorem ipsum dolor sit amet'); | ||
$output->write(new \ArrayIterator(array('', '', ''))); | ||
$output->title('Fourth title'); | ||
|
||
//Ensure have manual control over number of blank lines: | ||
$output->writeln('Lorem ipsum dolor sit amet'); | ||
$output->writeln(new \ArrayIterator(array('', ''))); //Should append an extra blank line | ||
$output->title('Fifth title'); | ||
|
||
$output->writeln('Lorem ipsum dolor sit amet'); | ||
$output->newLine(2); //Should append an extra blank line | ||
$output->title('Fifth title'); | ||
}; |
32 changes: 32 additions & 0 deletions
32
...ny/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_4_with_iterators.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Lorem ipsum dolor sit amet | ||
|
||
First title | ||
=========== | ||
|
||
Lorem ipsum dolor sit amet | ||
|
||
Second title | ||
============ | ||
|
||
Lorem ipsum dolor sit amet | ||
|
||
Third title | ||
=========== | ||
|
||
Lorem ipsum dolor sit amet | ||
|
||
Fourth title | ||
============ | ||
|
||
Lorem ipsum dolor sit amet | ||
|
||
|
||
Fifth title | ||
=========== | ||
|
||
Lorem ipsum dolor sit amet | ||
|
||
|
||
Fifth title | ||
=========== | ||
|