File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ public function __construct(string $cwd, array $argv)
98
98
$ this ->providedOptions [$ optionName ] = $ optionArgument ;
99
99
}
100
100
} else {
101
+ if ($ this ->getOptionArgumentAfterAssign ($ arg ) !== null ) {
102
+ throw new InvalidCliException ("Option -- $ optionName does not accept arguments, see --help " );
103
+ }
104
+
101
105
$ this ->providedOptions [$ optionName ] = true ;
102
106
}
103
107
}
@@ -122,7 +126,10 @@ private function isOptionWithRequiredValue(string $optionName): bool
122
126
private function getKnownOptionName (string $ option ): ?string
123
127
{
124
128
foreach (self ::OPTIONS as $ knownOption => $ needsArgument ) {
125
- if (strpos ($ option , $ knownOption ) === 0 ) {
129
+ if (
130
+ strpos ($ option , $ knownOption ) === 0
131
+ && (strlen ($ option ) === strlen ($ knownOption ) || $ option [strlen ($ knownOption )] === '= ' )
132
+ ) {
126
133
return $ knownOption ;
127
134
}
128
135
}
Original file line number Diff line number Diff line change @@ -115,6 +115,16 @@ public function validationDataProvider(): iterable
115
115
['bin/script.php ' , '--composer-json= ' ],
116
116
];
117
117
118
+ yield 'valid option is substring of provided option ' => [
119
+ 'Unknown option --configuration=foo, see --help ' ,
120
+ ['bin/script.php ' , '--configuration=foo ' ],
121
+ ];
122
+
123
+ yield 'argument-less option with argument ' => [
124
+ 'Option --verbose does not accept arguments, see --help ' ,
125
+ ['bin/script.php ' , '--verbose=foo ' ],
126
+ ];
127
+
118
128
yield 'suggestion #1 ' => [
119
129
'Unknown option --hep, did you mean --help? ' ,
120
130
['bin/script.php ' , '--hep ' ],
You can’t perform that action at this time.
0 commit comments