Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chalasr merged 1 commit intosymfony:masterfromogizanagi:console/sf_style_write_iterable
Apr 9, 2018
Merged

[Console] Support iterable in SymfonyStyle::write/writeln#26863

chalasr merged 1 commit intosymfony:masterfromogizanagi:console/sf_style_write_iterable
Apr 9, 2018

Conversation

@ogizanagi
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsN/A
LicenseMIT
Doc PRN/A

Relates to#26847.

This would enable iterables benefits even when usingSymfonyStyle output.

@ro0NL
Copy link
Contributor

ro0NL commentedApr 8, 2018
edited
Loading

Should/Can we updatestring|array tostring|iterable PHPdoc in StyleInterface etc?

@ogizanagi
Copy link
ContributorAuthor

These methods are not part ofStyleInterface, butOutputInterface which is already up to date. TheStyleInterface methods are unchanged.

@ogizanagi
Copy link
ContributorAuthor

(I'm not convinced enabling support for iterables inStyleInterface methods is worth it, appart maybelisting but there is already anarray typehint).

@ro0NL
Copy link
Contributor

ro0NL commentedApr 8, 2018
edited
Loading

StyleInterface could benefit the same upgrade (we could yield the lines fromcreateBlock()).

edit:

I'm not convinced enabling support for iterables in StyleInterface methods is worth it

Well we did it forwrite() why notsuccess() and such =/ I agree it's probably less common to use here 😅

@ogizanagi
Copy link
ContributorAuthor

ogizanagi commentedApr 8, 2018
edited
Loading

I don't see many use cases for generators when displaying blocks, title, sections, etc... whilewrite/writeln are important to update because theSymfonyStyle can be passed along to any method/class requiring anOutputInterface and that could really benefit from generators memory saving.

ro0NL reacted with thumbs up emoji

Copy link
Member

@chalasrchalasr left a 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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sixth :)

@chalasr
Copy link
Member

Thank you@ogizanagi.

@chalasrchalasr merged commitd66827e intosymfony:masterApr 9, 2018
chalasr added a commit that referenced this pull requestApr 9, 2018
…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     <!-- seehttps://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/ARelates to#26847.This would enable iterables benefits even when using `SymfonyStyle` output.Commits-------d66827e [Console] Support iterable in SymfonyStyle::write/writeln
@ogizanagiogizanagi deleted the console/sf_style_write_iterable branchApril 9, 2018 07:51
// Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer
returnarray_map(function ($value) {
returnsubstr($value, -4);
},array_merge(array($this->bufferedOutput->fetch()), (array)$messages));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

so thefetch part was useless all along?

Copy link
ContributorAuthor

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.

@Tobion
Copy link
Contributor

Nice change@ogizanagi . Thanks

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@TobionTobionTobion left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

5 participants

@ogizanagi@ro0NL@chalasr@Tobion@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp