Skip to content

[Console] ChoiceQuestion - invalid error handling if a choice array is empty. #22842

Closed
@victorKochkarev

Description

@victorKochkarev
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.2.8

ChoiceQuestion - invalid error handling if a choice array is empty.

protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getHelper('question');
        $question = new ChoiceQuestion(
            'Please select your favorite color (defaults to red)',
            [],
            0
        );
        
        $question->setErrorMessage('Color %s is invalid.');

        $color = $helper->ask($input, $output, $question);
        $output->writeln('You have just selected: '.$color);

    }

Results into infinite not descriptive warning/error message loop:
screenshot from 2017-05-22 00-18-02

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions