本文整理匯總了PHP中Symfony\Component\Console\Question\Question::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Question::__construct方法的具體用法?PHP Question::__construct怎麽用?PHP Question::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Question\Question
的用法示例。
在下文中一共展示了Question::__construct方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Constructor.
*
* @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 function __construct($question, array $choices, $default = null)
{
parent::__construct($question, $default);
$this->choices = $choices;
$this->setValidator($this->getDefaultValidator());
$this->setAutocompleterValues($choices);
}
示例2: __construct
/**
* Modify our question on construct to apply some pretty formatting.
*
* @param string $question The question to ask to the user
* @param mixed $default The default answer to return if the user enters nothing
*/
public function __construct($question, $default = NULL)
{
// Append our default value?
if ($default !== NULL) {
$question = $question . " <comment>[default: \"{$default}\"]</comment>";
}
$question = $question . ': ';
parent::__construct($question, $default);
}
示例3: __construct
/**
*
* @param string $question The question to be asked
* @param string|null $default the default (optional)
*/
public function __construct(string $question, string $default = null)
{
parent::__construct($question, $default);
$this->setFormatter(new formatter\WithDefault());
}
示例4: __construct
public function __construct($question, array $rules, $default = null)
{
parent::__construct($question, $default);
$this->rules = $rules;
$this->setValidator($this->validator());
}