Copied!

Represents a choice question.

CloneableInstantiable
Methods
public __construct(string $question, array $choices, ?mixed $default = NULL)
 
  • param string $question The question to ask to the user
  • param array $choices The list of available choices
  • param mixed $default The default answer to return
public Symfony\Component\Console\Question\Question::getAutocompleterCallback() : ?callable
 

Gets the callback function used for the autocompleter.

public Symfony\Component\Console\Question\Question::getAutocompleterValues() : ?iterable
 

Gets values for the autocompleter.

public getChoices() : array
 

Returns available choices.

public Symfony\Component\Console\Question\Question::getDefault() : string|int|float|bool|?null
 

Returns the default answer.

public Symfony\Component\Console\Question\Question::getMaxAttempts() : ?int
 

Gets the maximum number of attempts.

Null means an unlimited number of attempts.

public Symfony\Component\Console\Question\Question::getNormalizer() : ?callable
 

Gets the normalizer for the response.

The normalizer can ba a callable (a string), a closure or a class implementing __invoke.

public getPrompt() : string
 

Gets the prompt for choices.

public Symfony\Component\Console\Question\Question::getQuestion() : string
 

Returns the question.

public Symfony\Component\Console\Question\Question::getValidator() : ?callable
 

Gets the validator for the question.

public Symfony\Component\Console\Question\Question::isHidden() : bool
 

Returns whether the user response must be hidden.

public Symfony\Component\Console\Question\Question::isHiddenFallback() : bool
 

In case the response cannot be hidden, whether to fallback on non-hidden question or not.

public Symfony\Component\Console\Question\Question::isMultiline() : bool
 

Returns whether the user response accepts newline characters.

public isMultiselect() : bool
 

Returns whether the choices are multiselect.

public Symfony\Component\Console\Question\Question::isTrimmable() : bool
public Symfony\Component\Console\Question\Question::setAutocompleterCallback(?callable $callback) : static
 

Sets the callback function used for the autocompleter.

The callback is passed the user input as argument and should return an iterable of corresponding suggestions.

  • return $this
public Symfony\Component\Console\Question\Question::setAutocompleterValues(?iterable $values) : static
 

Sets values for the autocompleter.

  • return $this
  • throws \LogicException
public setErrorMessage(string $errorMessage) : static
 

Sets the error message for invalid values.

The error message has a string placeholder (%s) for the invalid value.

  • return $this
public Symfony\Component\Console\Question\Question::setHidden(bool $hidden) : static
 

Sets whether the user response must be hidden or not.

  • return $this
  • throws \LogicException In case the autocompleter is also used
public Symfony\Component\Console\Question\Question::setHiddenFallback(bool $fallback) : static
 

Sets whether to fallback on non-hidden question if the response cannot be hidden.

  • return $this
public Symfony\Component\Console\Question\Question::setMaxAttempts(?int $attempts) : static
 

Sets the maximum number of attempts.

Null means an unlimited number of attempts.

  • return $this
  • throws \InvalidArgumentException in case the number of attempts is invalid
public Symfony\Component\Console\Question\Question::setMultiline(bool $multiline) : static
 

Sets whether the user response should accept newline characters.

  • return $this
public setMultiselect(bool $multiselect) : static
 

Sets multiselect option.

When multiselect is set to true, multiple choices can be answered.

  • return $this
public Symfony\Component\Console\Question\Question::setNormalizer(callable $normalizer) : static
 

Sets a normalizer for the response.

The normalizer can be a callable (a string), a closure or a class implementing __invoke.

  • return $this
public setPrompt(string $prompt) : static
 

Sets the prompt for choices.

  • return $this
public Symfony\Component\Console\Question\Question::setTrimmable(bool $trimmable) : static
 
  • return $this
public Symfony\Component\Console\Question\Question::setValidator(?callable $validator) : static
 

Sets a validator for the question.

  • return $this
Methods
protected Symfony\Component\Console\Question\Question::isAssoc(array $array) : bool
Properties
private array $choices
private string $errorMessage = 'Value "%s" is invalid'
private bool $multiselect = false
private string $prompt = ' > '
Methods
private getDefaultValidator() : callable
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration