Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / vendor / drush / drush / src / Symfony / IndiscriminateInputDefinition.php
1 <?php
2
3 namespace Drush\Symfony;
4
5 use Symfony\Component\Console\Input\InputDefinition;
6 use Symfony\Component\Console\Input\InputOption;
7 use Symfony\Component\Console\Exception\InvalidArgumentException;
8 use Symfony\Component\Console\Exception\LogicException;
9
10 /**
11  * This is an InputDefinition that allows any option to be considered valid.
12  * Used when passing a command through to another dispatcher that will do
13  * the option validation.
14  *
15  * We use this instead of a LessStrictArgvInput in cases where we do not
16  * know in advance whether the input should be handled indiscriminately.
17  * In other words, an IndiscriminateInputDefinition is attached to individual
18  * Commands that should accept any option, whereas a LessStrictArgvInput
19  * should be used to make all command skip option validation.
20  */
21 class IndiscriminateInputDefinition extends InputDefinition
22 {
23     /**
24      * @inheritdoc
25      */
26     public function hasShortcut($name)
27     {
28         return true;
29     }
30
31     /**
32      * @inheritdoc
33      */
34     public function hasOption($name)
35     {
36         return true;
37     }
38
39     /**
40      * @inheritdoc
41      */
42     public function getOption($name)
43     {
44         if (parent::hasOption($name)) {
45             return parent::getOption($name);
46         }
47         return new InputOption($name, null, InputOption::VALUE_OPTIONAL, '', []);
48     }
49 }