Represents a yes/no question.
- Full name:
\Symfony\Component\Console\Question\ConfirmationQuestion
- Parent class:
\Symfony\Component\Console\Question\Question
private $trueAnswerRegex
public __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i'): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$question |
string | The question to ask to the user |
$default |
bool | The default answer to return, true or false |
$trueAnswerRegex |
string | A regex to match the "yes" answer |
Returns the default answer normalizer.
private getDefaultNormalizer(): callable
public __construct(string $question, string|bool|int|float|null $default = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$question |
string | The question to ask to the user |
$default |
string|bool|int|float|null | The default answer to return if the user enters nothing |
Returns the question.
public getQuestion(): string
Returns the default answer.
public getDefault(): string|bool|int|float|null
Returns whether the user response accepts newline characters.
public isMultiline(): bool
Sets whether the user response should accept newline characters.
public setMultiline(bool $multiline): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$multiline |
bool |
isHidden
Returns whether the user response must be hidden.
public isHidden(): bool
setHidden
Sets whether the user response must be hidden or not.
public setHidden(bool $hidden): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$hidden |
bool |
isHiddenFallback
In case the response cannot be hidden, whether to fallback on non-hidden question or not.
public isHiddenFallback(): bool
setHiddenFallback
Sets whether to fallback on non-hidden question if the response cannot be hidden.
public setHiddenFallback(bool $fallback): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$fallback |
bool |
Gets values for the autocompleter.
public getAutocompleterValues(): iterable|null
Sets values for the autocompleter.
public setAutocompleterValues(?iterable $values): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$values |
?iterable |
Gets the callback function used for the autocompleter.
public getAutocompleterCallback(): ?callable
Sets the callback function used for the autocompleter.
public setAutocompleterCallback(callable $callback = null): $this
The callback is passed the user input as argument and should return an iterable of corresponding suggestions.
Parameters:
Parameter | Type | Description |
---|---|---|
$callback |
callable |
Sets a validator for the question.
public setValidator(callable $validator = null): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$validator |
callable |
Gets the validator for the question.
public getValidator(): callable|null
Sets the maximum number of attempts.
public setMaxAttempts(?int $attempts): $this
Null means an unlimited number of attempts.
Parameters:
Parameter | Type | Description |
---|---|---|
$attempts |
?int |
Gets the maximum number of attempts.
public getMaxAttempts(): int|null
Null means an unlimited number of attempts.
Sets a normalizer for the response.
public setNormalizer(callable $normalizer): $this
The normalizer can be a callable (a string), a closure or a class implementing __invoke.
Parameters:
Parameter | Type | Description |
---|---|---|
$normalizer |
callable |
Gets the normalizer for the response.
public getNormalizer(): callable|null
The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
protected isAssoc(array $array): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$array |
array |
public isTrimmable(): bool
public setTrimmable(bool $trimmable): $this
Parameters:
Parameter | Type | Description |
---|---|---|
$trimmable |
bool |