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] Fixed SymfonyQuestionHelper multi-choice with defaults#19100

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

Conversation

@sstok
Copy link
Contributor

QA
Bug Fix?yes
New Feature?no
BC Breaks?no
Deprecations?no
Tests Pass?yes
Fixed Tickets
LicenseMIT
Doc PR

When you use the SymfonyStyle with a multi-choice question and multiple defaults.
You get an notice because the key is used as-is0,1 instead of splitting the value.

This pull-request changes the SymfonyQuestionHelper to checks if the Choice is a multi-choice
and displays the selected values correctly[blue, yellow].

Note: Tests are missing, but both the SymfonyStyle and SymfonyQuestionHelper classes
have almost no tests. Making it really hard 😇 hopefully#19097 will make this easier 👍

* Returns whether the choices are multiselect.
*
* @return bool
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should beisMultiselect and i would add it right aftersetMultiselect

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done

@sstoksstokforce-pushed thebug-console-multi-choice-symfonyStyle branch from53a0c38 tobcb4f09CompareJune 18, 2016 16:47
@sstoksstok changed the titleFixed SymfonyQuestionHelper multi-choice with defaults[Console] Fixed SymfonyQuestionHelper multi-choice with defaultsJun 18, 2016
@chalasr
Copy link
Member

👍 (needs some tests).

@sstok
Copy link
ContributorAuthor

Will add the test later today 👍 thanks for working on it.

Status: Needs work

@sstoksstokforce-pushed thebug-console-multi-choice-symfonyStyle branch frombcb4f09 to0574adaCompareJune 21, 2016 11:55
@sstok
Copy link
ContributorAuthor

Tests added 👍

Status: Needs review

@chalasr
Copy link
Member

chalasr commentedJun 21, 2016
edited
Loading

@sstok Your test fails on appveyor, the output is different than the expected one.
I recently faced this issue.

Your test expects: "What is your favorite superhero? [Spiderman]" but the output is:

It's because the SymfonyQuestionHelper decorates the output, disable it and tests should pass:

- return new StreamOutput(fopen('php://memory', 'r+', false));+ $output = new StreamOutput(fopen('php://memory', 'r+', false));+ $output->setDecorated(false);++ return $output;

@ro0NL
Copy link
Contributor

ro0NL commentedJun 21, 2016
edited
Loading

Btw specifying defaults as"1,2" is that to reflect user input, format-wise? I.e. why not
array('1', '2')?

@sstok
Copy link
ContributorAuthor

sstok commentedJun 22, 2016
edited
Loading

@ro0NL That would be a new feature, this pr is about fixing the SymfonyQuestionHelper 👍

@chalasr Thanks for the tip 👍

$choices =$question->getChoices();
$default =array_map('trim',explode(',',$default));

foreach ($defaultas &$defaultVal) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid using references here?

foreach ($defaultas$key =>$value) {$default[$key] =$choices[$value];}

@ro0NL
Copy link
Contributor

@sstok understand, just wondered

@sstoksstokforce-pushed thebug-console-multi-choice-symfonyStyle branch from1637d7e to79815a9CompareJune 22, 2016 09:23
@sstok
Copy link
ContributorAuthor

Squashed and rebased.

@fabpot
Copy link
Member

Thank you@sstok.

fabpot added a commit that referenced this pull requestJun 22, 2016
…faults (sstok)This PR was submitted for the 2.8 branch but it was merged into the 2.7 branch instead (closes#19100).Discussion----------[Console] Fixed SymfonyQuestionHelper multi-choice with defaults|Q            |A  ||---          |---||Bug Fix?     |yes||New Feature? |no ||BC Breaks?   |no ||Deprecations?|no ||Tests Pass?  |yes||Fixed Tickets|   ||License      |MIT||Doc PR       |   |When you use the SymfonyStyle with a multi-choice question and multiple defaults.You get an notice because the key is used as-is `0,1` instead of splitting the value.This pull-request changes the SymfonyQuestionHelper to checks if the Choice is a multi-choiceand displays the selected values correctly `[blue, yellow]`.Note: Tests are missing, but both the SymfonyStyle and SymfonyQuestionHelper classeshave almost no tests. Making it really hard 😇 hopefully#19097 will make this easier 👍Commits-------a8f6f85 Fixed SymfonyQuestionHelper multi-choice with defaults
@fabpotfabpot closed thisJun 22, 2016
@sstoksstok deleted the bug-console-multi-choice-symfonyStyle branchJune 22, 2016 12:12
@sstok
Copy link
ContributorAuthor

@fabpot can you please merge the 2.7 up-to the master branch 👍

@sstok
Copy link
ContributorAuthor

Thanks ;)

This was referencedJun 30, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@sstok@chalasr@ro0NL@fabpot@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp