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] fix a bug when you are passing a default value and passing -n would output the index#25521

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

@Simperfit
Copy link
Contributor

@SimperfitSimperfit commentedDec 16, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#25470
LicenseMIT
Doc PR

We are fixing a bug when you are using a default value with -n, it would output the index instead of the value.

Simple reproducerSimperfit/symfony-reproducer@5079dd1?diff=split#diff-77efcc28bc5309e1af9ac07a1e073009R40

Copy link
Contributor

@srozesroze left a comment

Choose a reason for hiding this comment

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

You are missing a test sir!

}

if (!$input->isInteractive()) {
$isInteractive = !$input->isInteractive();
Copy link
Contributor

Choose a reason for hiding this comment

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

$isNotInteractive ?

if (!$input->isInteractive()) {
$isInteractive = !$input->isInteractive();

if ($isInteractive &&$questioninstanceof ChoiceQuestion) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Or I think that you should just putif ($question instanceof ChoiceQuestion) { within the existingif (!$input->isInteractive()) {.

Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn’t theChoiceQuestion itself take care of returning the correct default value ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't know if we should nest theses ifs, IMO its clearer like this.

@mathroc I wanted to it like this firstly but it's hard since the getDefault is called without the choices being changed.

Copy link
ContributorAuthor

@SimperfitSimperfitDec 16, 2017
edited
Loading

Choose a reason for hiding this comment

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

Nvm@sroze you are right, it avoids one test for nothing.

@SimperfitSimperfitforce-pushed thebugfix/fix-a-wrong-output-when-passing-in-interactive-mode branch 2 times, most recently from338c78d to56ccf18CompareDecember 16, 2017 11:44
@SimperfitSimperfit changed the base branch frommaster to2.7December 16, 2017 11:46
@SimperfitSimperfitforce-pushed thebugfix/fix-a-wrong-output-when-passing-in-interactive-mode branch from56ccf18 to066108aCompareDecember 16, 2017 11:47
@Simperfit
Copy link
ContributorAuthor

Test added

@Simperfit
Copy link
ContributorAuthor

Status: Needs Review

$this->assertEquals(array('Superman','Batman'),$questionHelper->ask($this->createInputInterfaceMock(),$this->createOutputInterface(),$question));

$question =newChoiceQuestion('What is your favorite superhero?',$heroes,0);
// We are supposed to get the default value since we are in interactive mode
Copy link
Contributor

Choose a reason for hiding this comment

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

since we arenot in interactive mode

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks! forgot that little word :p

@mathroc
Copy link
Contributor

mathroc commentedDec 16, 2017
edited
Loading

thx@Simperfit to have taken a look at this. there’s still something odd.

I’m not sure the default value passed to the question should be its key, the doc comment says@param mixed $default The default answer to return so maybe the problem is instead that SymfonyStyle is converting the default value to its key

ps: but to be fair, that’s whatthe documentation is doing

@Simperfit
Copy link
ContributorAuthor

@mathroc SymfonyStyle is transforming this array. So it has value -> key. This fixes both behaviour when passing the key or the value look at the reproducer i've done to be sure that nothing will be broken :Simperfit/symfony-reproducer@b37a2a5

mathroc reacted with thumbs up emoji

@SimperfitSimperfitforce-pushed thebugfix/fix-a-wrong-output-when-passing-in-interactive-mode branch 3 times, most recently fromf878424 to0704f80CompareDecember 16, 2017 12:11
@SimperfitSimperfitforce-pushed thebugfix/fix-a-wrong-output-when-passing-in-interactive-mode branch from0704f80 to41ffc69CompareDecember 16, 2017 12:12
@Simperfit
Copy link
ContributorAuthor

Travis failure is unrelated

@nicolas-grekasnicolas-grekas added this to the2.7 milestoneDec 18, 2017
@nicolas-grekas
Copy link
Member

Thank you@Simperfit.

@nicolas-grekasnicolas-grekas merged commit41ffc69 intosymfony:2.7Dec 18, 2017
nicolas-grekas added a commit that referenced this pull requestDec 18, 2017
…nd passing -n would output the index (Simperfit)This PR was merged into the 2.7 branch.Discussion----------[Console] fix a bug when you are passing a default value and passing -n would output the index| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks?    | no| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->| Tests pass?   | yes| Fixed tickets |#25470| License       | MIT| Doc PR        |We are fixing a bug when you are using a default value with -n, it would output the index instead of the value.Simple reproducerSimperfit/symfony-reproducer@5079dd1?diff=split#diff-77efcc28bc5309e1af9ac07a1e073009R40Commits-------41ffc69 [Console] fix a bug when you are passing a default value and passing -n would ouput the index
@SimperfitSimperfit deleted the bugfix/fix-a-wrong-output-when-passing-in-interactive-mode branchDecember 19, 2017 07:59
greg0ire added a commit to greg0ire/Behat that referenced this pull requestMay 21, 2018
This is how the QuestionHelper API was intended to be used, but it onlyhas been so since a recent bugfix.Seesymfony/symfony#25521FixesBehat#1151
@greg0iregreg0ire mentioned this pull requestMay 21, 2018
greg0ire added a commit to greg0ire/Behat that referenced this pull requestMay 21, 2018
This is how the QuestionHelper API was intended to be used, but it onlyhas been so since a recent bugfix.Seesymfony/symfony#25521FixesBehat#1151
greg0ire added a commit to greg0ire/Behat that referenced this pull requestMay 21, 2018
This is how the QuestionHelper API was intended to be used, but it onlyhas been so since a recent bugfix.Seesymfony/symfony#25521FixesBehat#1151
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh approved these changes

@chalasrchalasrchalasr approved these changes

+2 more reviewers

@mathrocmathrocmathroc left review comments

@srozesrozesroze requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

7 participants

@Simperfit@mathroc@nicolas-grekas@sroze@xabbuh@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp