1 | <?php |
||
23 | class ArgvArgs implements RawArgs |
||
24 | { |
||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $scriptName; |
||
29 | |||
30 | /** |
||
31 | * @var string[] |
||
32 | */ |
||
33 | private $tokens; |
||
34 | |||
35 | /** |
||
36 | * Creates the console arguments. |
||
37 | * |
||
38 | * @param array $argv The contents of the "argv" variable or `null` to read |
||
|
|||
39 | * the global "argv" variable. |
||
40 | */ |
||
41 | 5 | public function __construct(array $argv = null) |
|
42 | { |
||
43 | 5 | if (null === $argv) { |
|
44 | 1 | $argv = $_SERVER['argv']; |
|
45 | } |
||
46 | |||
47 | 5 | $this->scriptName = array_shift($argv); |
|
48 | 5 | $this->tokens = $argv; |
|
49 | 5 | } |
|
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | 3 | public function getScriptName() |
|
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | 1 | public function hasToken($token) |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 3 | public function getTokens() |
|
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | 1 | public function toString($scriptName = true) |
|
88 | } |
||
89 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.