-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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] Fixed SymfonyQuestionHelper multi-choice with defaults #19100
Conversation
* | ||
* @return bool | ||
*/ | ||
public function isMultiSelect() |
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.
Should be isMultiselect
and i would add it right after setMultiselect
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.
Done
53a0c38
to
bcb4f09
Compare
👍 (needs some tests). |
Will add the test later today 👍 thanks for working on it. Status: Needs work |
bcb4f09
to
0574ada
Compare
Tests added 👍 Status: Needs review |
@sstok Your test fails on appveyor, the output is different than the expected one. 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; |
Btw specifying defaults as |
$choices = $question->getChoices(); | ||
$default = array_map('trim', explode(',', $default)); | ||
|
||
foreach ($default as &$defaultVal) { |
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.
Can we avoid using references here?
foreach ($default as $key => $value) {
$default[$key] = $choices[$value];
}
@sstok understand, just wondered |
1637d7e
to
79815a9
Compare
Squashed and rebased. |
Thank you @sstok. |
…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-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 👍 Commits ------- a8f6f85 Fixed SymfonyQuestionHelper multi-choice with defaults
@fabpot can you please merge the 2.7 up-to the master branch 👍 |
Thanks ;) |
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-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 👍