Copied!

Represents a yes/no question.

CloneableInstantiable
Methods
public __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i')
 
  • param string $question The question to ask to the user
  • param bool $default The default answer to return, true or false
  • param string $trueAnswerRegex A regex to match the "yes" answer
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 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 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 Symfony\Component\Console\Question\Question::isTrimmable() : bool
public Symfony\Component\Console\Question\Question::setAutocompleterCallback(?callable $callback = NULL) : 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 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 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 Symfony\Component\Console\Question\Question::setTrimmable(bool $trimmable) : static
 
  • return $this
public Symfony\Component\Console\Question\Question::setValidator(?callable $validator = NULL) : static
 

Sets a validator for the question.

  • return $this
Methods
protected Symfony\Component\Console\Question\Question::isAssoc(array $array)
 
  • return bool
Properties
private string $trueAnswerRegex
Methods
private getDefaultNormalizer() : callable
 

Returns the default answer normalizer.

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration