@@ -16,7 +16,7 @@ class Parser
16
16
*
17
17
* @throws \InvalidArgumentException
18
18
*/
19
- public static function parse ($ expression )
19
+ public static function parse (string $ expression )
20
20
{
21
21
$ name = static ::name ($ expression );
22
22
@@ -35,7 +35,7 @@ public static function parse($expression)
35
35
*
36
36
* @throws \InvalidArgumentException
37
37
*/
38
- protected static function name ($ expression )
38
+ protected static function name (string $ expression )
39
39
{
40
40
if (! preg_match ('/[^\s]+/ ' , $ expression , $ matches )) {
41
41
throw new InvalidArgumentException ('Unable to determine command name from signature. ' );
@@ -45,7 +45,7 @@ protected static function name($expression)
45
45
}
46
46
47
47
/**
48
- * Extract all of the parameters from the tokens.
48
+ * Extract all parameters from the tokens.
49
49
*
50
50
* @param array $tokens
51
51
* @return array
@@ -57,7 +57,7 @@ protected static function parameters(array $tokens)
57
57
$ options = [];
58
58
59
59
foreach ($ tokens as $ token ) {
60
- if (preg_match ('/-{2,}(.*)/ ' , $ token , $ matches )) {
60
+ if (preg_match ('/^ -{2,}(.*)/ ' , $ token , $ matches )) {
61
61
$ options [] = static ::parseOption ($ matches [1 ]);
62
62
} else {
63
63
$ arguments [] = static ::parseArgument ($ token );
@@ -73,7 +73,7 @@ protected static function parameters(array $tokens)
73
73
* @param string $token
74
74
* @return \Symfony\Component\Console\Input\InputArgument
75
75
*/
76
- protected static function parseArgument ($ token )
76
+ protected static function parseArgument (string $ token )
77
77
{
78
78
[$ token , $ description ] = static ::extractDescription ($ token );
79
79
@@ -99,7 +99,7 @@ protected static function parseArgument($token)
99
99
* @param string $token
100
100
* @return \Symfony\Component\Console\Input\InputOption
101
101
*/
102
- protected static function parseOption ($ token )
102
+ protected static function parseOption (string $ token )
103
103
{
104
104
[$ token , $ description ] = static ::extractDescription ($ token );
105
105
@@ -132,7 +132,7 @@ protected static function parseOption($token)
132
132
* @param string $token
133
133
* @return array
134
134
*/
135
- protected static function extractDescription ($ token )
135
+ protected static function extractDescription (string $ token )
136
136
{
137
137
$ parts = preg_split ('/\s+:\s+/ ' , trim ($ token ), 2 );
138
138
0 commit comments