public function SymfonyQuestionHelper::ask in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Helper/SymfonyQuestionHelper.php \Symfony\Component\Console\Helper\SymfonyQuestionHelper::ask()
Asks a question to the user.
Parameters
InputInterface $input An InputInterface instance:
OutputInterface $output An OutputInterface instance:
Question $question The question to ask:
Return value
string The user answer
Throws
\RuntimeException If there is no data to read in the input stream
Overrides QuestionHelper::ask
File
- vendor/
symfony/ console/ Helper/ SymfonyQuestionHelper.php, line 31
Class
- SymfonyQuestionHelper
- Symfony Style Guide compliant question helper.
Namespace
Symfony\Component\Console\HelperCode
public function ask(InputInterface $input, OutputInterface $output, Question $question) {
$validator = $question
->getValidator();
$question
->setValidator(function ($value) use ($validator) {
if (null !== $validator && is_callable($validator)) {
$value = $validator($value);
}
// make required
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) {
throw new \Exception('A value is required.');
}
return $value;
});
return parent::ask($input, $output, $question);
}