-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
IndiscriminateInputDefinition.php
47 lines (42 loc) · 1.24 KB
/
IndiscriminateInputDefinition.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Drush\Symfony;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
/**
* This is an InputDefinition that allows any option to be considered valid.
* Used when passing a command through to another dispatcher that will do
* the option validation.
*
* We use this instead of a LessStrictArgvInput in cases where we do not
* know in advance whether the input should be handled indiscriminately.
* In other words, an IndiscriminateInputDefinition is attached to individual
* Commands that should accept any option, whereas a LessStrictArgvInput
* should be used to make all command skip option validation.
*/
class IndiscriminateInputDefinition extends InputDefinition
{
/**
* @inheritdoc
*/
public function hasShortcut(string $name): bool
{
return true;
}
/**
* @inheritdoc
*/
public function hasOption(string $name): bool
{
return true;
}
/**
* @inheritdoc
*/
public function getOption(string $name): InputOption
{
if (parent::hasOption($name)) {
return parent::getOption($name);
}
return new InputOption($name, null, InputOption::VALUE_OPTIONAL, '', []);
}
}