/** * 构造方法 * @param string $question 问题 * @param array $choices 选项 * @param mixed $default 默认答案 */ public function __construct($question, array $choices, $default = null) { parent::__construct($question, $default); $this->choices = $choices; $this->setValidator($this->getDefaultValidator()); $this->setAutocompleterValues($choices); }
/** * 构造方法 * @param string $question 问题 * @param bool $default 默认答案 * @param string $trueAnswerRegex 验证正则 */ public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i') { parent::__construct($question, (bool) $default); $this->trueAnswerRegex = $trueAnswerRegex; $this->setNormalizer($this->getDefaultNormalizer()); }