Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/console/Helper/SymfonyQuestionHelper.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\Console\Helper; | 12 namespace Symfony\Component\Console\Helper; |
13 | 13 |
14 use Symfony\Component\Console\Exception\LogicException; | 14 use Symfony\Component\Console\Exception\LogicException; |
15 use Symfony\Component\Console\Formatter\OutputFormatter; | |
15 use Symfony\Component\Console\Input\InputInterface; | 16 use Symfony\Component\Console\Input\InputInterface; |
16 use Symfony\Component\Console\Output\OutputInterface; | 17 use Symfony\Component\Console\Output\OutputInterface; |
17 use Symfony\Component\Console\Question\ChoiceQuestion; | 18 use Symfony\Component\Console\Question\ChoiceQuestion; |
18 use Symfony\Component\Console\Question\ConfirmationQuestion; | 19 use Symfony\Component\Console\Question\ConfirmationQuestion; |
19 use Symfony\Component\Console\Question\Question; | 20 use Symfony\Component\Console\Question\Question; |
20 use Symfony\Component\Console\Style\SymfonyStyle; | 21 use Symfony\Component\Console\Style\SymfonyStyle; |
21 use Symfony\Component\Console\Formatter\OutputFormatter; | |
22 | 22 |
23 /** | 23 /** |
24 * Symfony Style Guide compliant question helper. | 24 * Symfony Style Guide compliant question helper. |
25 * | 25 * |
26 * @author Kevin Bond <kevinbond@gmail.com> | 26 * @author Kevin Bond <kevinbond@gmail.com> |
38 $question->setValidator(function ($value) use ($validator) { | 38 $question->setValidator(function ($value) use ($validator) { |
39 if (null !== $validator) { | 39 if (null !== $validator) { |
40 $value = $validator($value); | 40 $value = $validator($value); |
41 } else { | 41 } else { |
42 // make required | 42 // make required |
43 if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) { | 43 if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) { |
44 @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED); | 44 @trigger_error('The default question validator is deprecated since Symfony 3.3 and will not be used anymore in version 4.0. Set a custom question validator if needed.', E_USER_DEPRECATED); |
45 | 45 |
46 throw new LogicException('A value is required.'); | 46 throw new LogicException('A value is required.'); |
47 } | 47 } |
48 } | 48 } |
84 | 84 |
85 break; | 85 break; |
86 | 86 |
87 case $question instanceof ChoiceQuestion: | 87 case $question instanceof ChoiceQuestion: |
88 $choices = $question->getChoices(); | 88 $choices = $question->getChoices(); |
89 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default])); | 89 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default)); |
90 | 90 |
91 break; | 91 break; |
92 | 92 |
93 default: | 93 default: |
94 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default)); | 94 $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default)); |