Properties

$question

$question : 

Type

$attempts

$attempts : 

Type

$hidden

$hidden : 

Type

$hiddenFallback

$hiddenFallback : 

Type

$autocompleterValues

$autocompleterValues : 

Type

$validator

$validator : 

Type

$default

$default : 

Type

$normalizer

$normalizer : 

Type

$choices

$choices : 

Type

$multiselect

$multiselect : 

Type

$prompt

$prompt : 

Type

$errorMessage

$errorMessage : 

Type

Methods

__construct()

__construct(string  $question, array  $choices, mixed  $default = null) 

构造方法

Parameters

string $question

问题

array $choices

选项

mixed $default

默认答案

getQuestion()

getQuestion() : string

获取问题

Returns

string

getDefault()

getDefault() : mixed

获取默认答案

Returns

mixed

isHidden()

isHidden() : boolean

是否隐藏答案

Returns

boolean

setHidden()

setHidden(boolean  $hidden) : \think\console\output\Question

隐藏答案

Parameters

boolean $hidden

Returns

\think\console\output\Question

isHiddenFallback()

isHiddenFallback() : boolean

不能被隐藏是否撤销

Returns

boolean

setHiddenFallback()

setHiddenFallback(boolean  $fallback) : \think\console\output\Question

设置不能被隐藏的时候的操作

Parameters

boolean $fallback

Returns

\think\console\output\Question

getAutocompleterValues()

getAutocompleterValues() : null|array|\Traversable

获取自动完成

Returns

null|array|\Traversable

setAutocompleterValues()

setAutocompleterValues(null|array|\Traversable  $values) : \think\console\output\Question

设置自动完成的值

Parameters

null|array|\Traversable $values

Throws

\InvalidArgumentException
\LogicException

Returns

\think\console\output\Question

setValidator()

setValidator(null|callable  $validator) : \think\console\output\Question

设置答案的验证器

Parameters

null|callable $validator

Returns

\think\console\output\Question

The current instance

getValidator()

getValidator() : null|callable

获取验证器

Returns

null|callable

setMaxAttempts()

setMaxAttempts(null|integer  $attempts) : \think\console\output\Question

设置最大重试次数

Parameters

null|integer $attempts

Throws

\InvalidArgumentException

Returns

\think\console\output\Question

getMaxAttempts()

getMaxAttempts() : null|integer

获取最大重试次数

Returns

null|integer

setNormalizer()

setNormalizer(string|\Closure  $normalizer) : \think\console\output\Question

设置响应的回调

Parameters

string|\Closure $normalizer

Returns

\think\console\output\Question

getNormalizer()

getNormalizer() : string|\Closure

获取响应回调 The normalizer can ba a callable (a string), a closure or a class implementing __invoke.

Returns

string|\Closure

getChoices()

getChoices() : array

可选项

Returns

array

setMultiselect()

setMultiselect(boolean  $multiselect) : self

设置可否多选

Parameters

boolean $multiselect

Returns

self

isMultiselect()

isMultiselect() 

getPrompt()

getPrompt() : string

获取提示

Returns

string

setPrompt()

setPrompt(string  $prompt) : self

设置提示

Parameters

string $prompt

Returns

self

setErrorMessage()

setErrorMessage(string  $errorMessage) : self

设置错误提示信息

Parameters

string $errorMessage

Returns

self

isAssoc()

isAssoc(  $array) 

Parameters

$array

getDefaultValidator()

getDefaultValidator() : callable

获取默认的验证方法

Returns

callable