class ChoiceQuestion extends Question
Represents a choice question.
| __construct(string $question, array $choices, mixed $default = null) | ||
| string | getQuestion() Returns the question. | from Question |
| mixed | getDefault() Returns the default answer. | from Question |
| bool | isHidden() Returns whether the user response must be hidden. | from Question |
| $this | setHidden(bool $hidden) Sets whether the user response must be hidden or not. | from Question |
| bool | isHiddenFallback() In case the response can not be hidden, whether to fallback on non-hidden question or not. | from Question |
| $this | setHiddenFallback(bool $fallback) Sets whether to fallback on non-hidden question if the response can not be hidden. | from Question |
| iterable|null | getAutocompleterValues() Gets values for the autocompleter. | from Question |
| $this | setAutocompleterValues(iterable|null $values) Sets values for the autocompleter. | from Question |
| $this | setValidator(callable $validator = null) Sets a validator for the question. | from Question |
| callable|null | getValidator() Gets the validator for the question. | from Question |
| $this | setMaxAttempts(int|null $attempts) Sets the maximum number of attempts. | from Question |
| int|null | getMaxAttempts() Gets the maximum number of attempts. | from Question |
| $this | setNormalizer(callable $normalizer) Sets a normalizer for the response. | from Question |
| callable | getNormalizer() Gets the normalizer for the response. | from Question |
| isAssoc($array) | from Question | |
| array | getChoices() Returns available choices. | |
| $this | setMultiselect(bool $multiselect) Sets multiselect option. | |
| bool | isMultiselect() Returns whether the choices are multiselect. | |
| string | getPrompt() Gets the prompt for choices. | |
| $this | setPrompt(string $prompt) Sets the prompt for choices. | |
| $this | setErrorMessage(string $errorMessage) Sets the error message for invalid values. |
| string | $question | The question to ask to the user |
| array | $choices | The list of available choices |
| mixed | $default | The default answer to return if the user enters nothing |
Returns the question.
| string |
Returns the default answer.
| mixed |
Returns whether the user response must be hidden.
| bool |
Sets whether the user response must be hidden or not.
| bool | $hidden |
| $this |
| LogicException | In case the autocompleter is also used |
In case the response can not be hidden, whether to fallback on non-hidden question or not.
| bool |
Sets whether to fallback on non-hidden question if the response can not be hidden.
| bool | $fallback |
| $this |
Gets values for the autocompleter.
| iterable|null |
Sets values for the autocompleter.
| iterable|null | $values |
| $this |
| InvalidArgumentException | |
| LogicException |
Sets a validator for the question.
| callable | $validator |
| $this |
Gets the validator for the question.
| callable|null |
Sets the maximum number of attempts.
Null means an unlimited number of attempts.
| int|null | $attempts |
| $this |
| InvalidArgumentException | in case the number of attempts is invalid |
Gets the maximum number of attempts.
Null means an unlimited number of attempts.
| int|null |
Sets a normalizer for the response.
The normalizer can be a callable (a string), a closure or a class implementing __invoke.
| callable | $normalizer |
| $this |
Gets the normalizer for the response.
The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
| callable |
| $array |
Returns available choices.
| array |
Sets multiselect option.
When multiselect is set to true, multiple choices can be answered.
| bool | $multiselect |
| $this |
Returns whether the choices are multiselect.
| bool |
Gets the prompt for choices.
| string |
Sets the prompt for choices.
| string | $prompt |
| $this |
Sets the error message for invalid values.
The error message has a string placeholder (%s) for the invalid value.
| string | $errorMessage |
| $this |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Question/ChoiceQuestion.html