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] ChoiceQuestion must have choices#22847

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

Closed
ro0NL wants to merge2 commits intosymfony:2.7fromro0NL:console-choice
Closed

[Console] ChoiceQuestion must have choices#22847

ro0NL wants to merge2 commits intosymfony:2.7fromro0NL:console-choice

Conversation

@ro0NL
Copy link
Contributor

@ro0NLro0NL commentedMay 22, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#22842
LicenseMIT
Doc PRsymfony/symfony-docs#...

@ro0NLro0NL changed the title[Console] Derive choice from default[Console] Bypass choice question without choicesMay 22, 2017
@nicolas-grekasnicolas-grekas added this to the2.7 milestoneMay 22, 2017
@javiereguiluz
Copy link
Member

What is the behavior proposed here? If you pass zero choices to a choice question, shouldn't we throw an exception?

OskarStark and skalpa reacted with thumbs up emoji

@ro0NL
Copy link
ContributorAuthor

ro0NL commentedMay 22, 2017
edited
Loading

Perhaps easier yes. Went for safe, as i wasnt really sure about the default value behavior (without any further options); or a default value being an unknown option.

The first (actually the case from the issue) also crashes, the latter is already validated when the question is optional.

So 👍 for throwing in the constructor, unless im unaware of any side effects :) but im fine either way.

@ro0NL
Copy link
ContributorAuthor

Updated.

@ro0NLro0NL changed the title[Console] Bypass choice question without choices[Console] ChoiceQuestion must have choicesMay 22, 2017
publicfunction__construct($question,array$choices,$default =null)
{
if (!$choices) {
thrownew \LogicException('Choice question must have at least 1 choice available.');
Copy link
Contributor

Choose a reason for hiding this comment

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

maybeInvalidArgumentException would be a better fit here?

ogizanagi and nunomaduro reacted with thumbs up emoji

Choose a reason for hiding this comment

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

@SpacePossum I totally agree with u.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

not sure if we really care :) imo. the argument is valid (an array), but it's domain is invalid (empty array). SoDomainException actually (imo.) but i thoughtLogicException is a bit more common in SF :)

Im fine either way.. as long as it's extends from logic i dont mind :)

Copy link
Contributor

Choose a reason for hiding this comment

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

changing it now would be BC break ;) anyway we should be good. If it is a domain level exception I would expect it to be thrown on count < 2 as one option does not leave anything to choose from either ;)

@fabpot
Copy link
Member

Thank you@ro0NL.

fabpot added a commit that referenced this pull requestMay 28, 2017
This PR was squashed before being merged into the 2.7 branch (closes#22847).Discussion----------[Console] ChoiceQuestion must have choices| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22842| License       | MIT| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features--><!--![image](https://cloud.githubusercontent.com/assets/1047696/26301309/1bfa52ca-3ee1-11e7-883b-f627f16e9d2f.png)-->Commits-------96e307f [Console] ChoiceQuestion must have choices
@fabpotfabpot closed thisMay 28, 2017
This was referencedMay 29, 2017
@ro0NLro0NL deleted the console-choice branchMay 30, 2017 07:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

+3 more reviewers

@nunomaduronunomaduronunomaduro left review comments

@SpacePossumSpacePossumSpacePossum left review comments

@ogizanagiogizanagiogizanagi approved these 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.

8 participants

@ro0NL@javiereguiluz@fabpot@ogizanagi@nunomaduro@SpacePossum@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp