@@ -38,21 +38,26 @@ public static function buildOptHelpName(array $names): string
3838 /**
3939 * check input is valid option value
4040 *
41- * @param mixed $val
41+ * @param string|bool $val
4242 *
4343 * @return bool
4444 */
45- public static function isOptionValue (mixed $ val ): bool
45+ public static function isOptionValue (string | bool $ val ): bool
4646 {
4747 if ($ val === false ) {
4848 return false ;
4949 }
5050
51- // if is: '', 0 || is not option name
51+ // if is '', 0 || is not option name
5252 if (!$ val || $ val [0 ] !== '- ' ) {
5353 return true ;
5454 }
5555
56+ // is option name.
57+ if (ltrim ($ val , '- ' )) {
58+ return false ;
59+ }
60+
5661 // ensure is option value.
5762 if (!str_contains ($ val , '= ' )) {
5863 return true ;
@@ -189,7 +194,7 @@ public static function parseArgv(array $params, array $config = []): array
189194
190195 // long-opt: (--<opt>)
191196 if (str_starts_with ($ option , '- ' )) {
192- $ option = substr ( $ option , 1 ) ;
197+ $ option = $ pn ;
193198 $ isLong = true ;
194199
195200 // long-opt: value specified inline (--<opt>=<value>)
@@ -207,7 +212,6 @@ public static function parseArgv(array $params, array $config = []): array
207212
208213 // next elem is value. fix: allow empty string ''
209214 if ($ value === true && !isset ($ boolOpts [$ option ]) && self ::isOptionValue ($ nxt )) {
210- // list(,$val) = each($params);
211215 $ value = $ nxt ;
212216 next ($ params );
213217
0 commit comments