src/console/docopt/DocoptParser.php
protected static function parseArgs(TokenIterator $tokens, \ArrayIterator $options, $optionsFirst = false) {
        $parsed = [];

        while ($tokens->current() !== null) {
            if ($tokens->current() == '--') {
                while ($tokens->current() !== null) {
                    $parsed[] = new Argument(null, $tokens->move());
                }
                return $parsed;
            }
            elseif (strStartsWith($tokens->current(), '--')) {
                $parsed = array_merge($parsed, static::parseLong($tokens, $options));
            }
            elseif (strStartsWith($tokens->current(), '-') && $tokens->current()!='-') {
                $parsed = array_merge($parsed, static::parseShort($tokens, $options));
            }
            elseif ($optionsFirst) {
                return array_merge($parsed, array_map(function($value) {
                    return new Argument(null, $value);
                }, $tokens->left()));
            }
            else {
                $parsed[] = new Argument(null, $tokens->move());
            }
        }
        return $parsed;
    }
protected static function parseArgs(TokenIterator $tokens, \ArrayIterator $options, $optionsFirst = false) {
        $parsed = [];

        while ($tokens->current() !== null) {
            if ($tokens->current() == '--') {
                while ($tokens->current() !== null) {
                    $parsed[] = new Argument(null, $tokens->move());
                }
                return $parsed;
            }
            elseif (strStartsWith($tokens->current(), '--')) {
                $parsed = array_merge($parsed, static::parseLong($tokens, $options));
            }
            elseif (strStartsWith($tokens->current(), '-') && $tokens->current()!='-') {
                $parsed = array_merge($parsed, static::parseShort($tokens, $options));
            }
            elseif ($optionsFirst) {
                return array_merge($parsed, array_map(function($value) {
                    return new Argument(null, $value);
                }, $tokens->left()));
            }
            else {
                $parsed[] = new Argument(null, $tokens->move());
            }
        }
        return $parsed;
    }
protected static function parseArgs ( TokenIterator $ tokens , \ ArrayIterator $ options , $ optionsFirst = false ) { $ parsed = [ ] ; while ( $ tokens -> current ( ) !== null ) { if ( $ tokens -> current ( ) == '--' ) { while ( $ tokens -> current ( ) !== null ) { $ parsed [ ] = new Argument ( null , $ tokens -> move ( ) ) ; } return $ parsed ; } elseif ( strStartsWith ( $ tokens -> current ( ) , '--' ) ) { $ parsed = array_merge ( $ parsed , static :: parseLong ( $ tokens , $ options ) ) ; } elseif ( strStartsWith ( $ tokens -> current ( ) , '-' ) && $ tokens -> current ( ) != '-' ) { $ parsed = array_merge ( $ parsed , static :: parseShort ( $ tokens , $ options ) ) ; } elseif ( $ optionsFirst ) { return array_merge ( $ parsed , array_map ( function ( $ value ) { return new Argument ( null , $ value ) ; } , $ tokens -> left ( ) ) ) ; } else { $ parsed [ ] = new Argument ( null , $ tokens -> move ( ) ) ; } } return $ parsed ; }
Parse arguments.

If options_first: argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;
else:             argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ;

@param  TokenIterator  $tokens
@param  \ArrayIterator $options
@param  bool           $optionsFirst [optional]

@return Pattern[]
Parse arguments .