@@ -120,10 +120,12 @@ public function parse(): array
120120
121121 foreach ($ this ->args as $ index => $ arg )
122122 {
123- if (! in_array ($ arg , $ this ->checked ) && $ index ! = 0 )
123+ if (in_array ($ arg , $ this ->checked ) || $ index = = 0 )
124124 {
125- $ this -> isOpt ( $ arg , $ index , TRUE ) ;
125+ continue ;
126126 }
127+
128+ $ this ->isOpt ($ arg , $ index , TRUE );
127129 }
128130
129131 return $ this ->ast ;
@@ -183,12 +185,11 @@ private function isOpt(string $opt, int $index, bool $toplevel = FALSE): bool
183185 {
184186 return $ this ->isValidLong (substr ($ param , 1 ), $ index );
185187 }
186- else
187- {
188- return $ this ->isValidLong ($ opt , $ index );
189- }
188+
189+ return $ this ->isValidLong ($ opt , $ index );
190190 }
191- elseif ($ toplevel )
191+
192+ if ($ toplevel )
192193 {
193194 trigger_error ('Superfluous argument: ' . $ opt , E_USER_NOTICE );
194195 }
@@ -235,18 +236,20 @@ private function isValidLong(string $opt, int $index): bool
235236
236237 foreach ($ this ->long as $ key => $ arg )
237238 {
238- if ($ opt = = substr ($ arg , 0 , strlen ($ opt )))
239+ if ($ opt ! = substr ($ arg , 0 , strlen ($ opt )))
239240 {
240- if (strlen ($ arg ) == strlen ($ opt ))
241- {
242- $ match = TRUE ;
243- $ args = $ key ;
244- }
245- elseif ($ arg [strlen ($ opt )] == ': ' || $ arg [strlen ($ opt )] == '; ' )
246- {
247- $ match = TRUE ;
248- $ args = $ key ;
249- }
241+ continue ;
242+ }
243+
244+ if (strlen ($ arg ) == strlen ($ opt ))
245+ {
246+ $ match = TRUE ;
247+ $ args = $ key ;
248+ }
249+ elseif ($ arg [strlen ($ opt )] == ': ' || $ arg [strlen ($ opt )] == '; ' )
250+ {
251+ $ match = TRUE ;
252+ $ args = $ key ;
250253 }
251254 }
252255
@@ -301,12 +304,11 @@ private function checkArgument(string $opt, int $index, int $pos, string $a): bo
301304 {
302305 return $ this ->checkArgument ($ opt , $ next , $ pos + 1 , $ a );
303306 }
304- else
305- {
306- return TRUE ;
307- }
307+
308+ return TRUE ;
308309 }
309- elseif ($ type == ': ' )
310+
311+ if ($ type == ': ' )
310312 {
311313 trigger_error ('Missing argument for - ' . $ opt , E_USER_WARNING );
312314 $ this ->error = TRUE ;
0 commit comments