public function parse(array $argv): self
    {
        $this->_normalizer = new Normalizer;

        \array_shift($argv);

        $argv    = $this->_normalizer->normalizeArgs($argv);
        $count   = \count($argv);
        $literal = false;

        for ($i = 0; $i < $count; $i++) {
            list($arg, $nextArg) = [$argv[$i], $argv[$i + 1] ?? null];

            if ($arg === '--') {
                $literal = true;
            } elseif ($arg[0] !== '-' || $literal) {
                $this->parseArgs($arg);
            } else {
                $i += (int) $this->parseOptions($arg, $nextArg);
            }
        }

        $this->validate();

        return $this;
    }
public function parse(array $argv): self
    {
        $this->_normalizer = new Normalizer;

        \array_shift($argv);

        $argv    = $this->_normalizer->normalizeArgs($argv);
        $count   = \count($argv);
        $literal = false;

        for ($i = 0; $i < $count; $i++) {
            list($arg, $nextArg) = [$argv[$i], $argv[$i + 1] ?? null];

            if ($arg === '--') {
                $literal = true;
            } elseif ($arg[0] !== '-' || $literal) {
                $this->parseArgs($arg);
            } else {
                $i += (int) $this->parseOptions($arg, $nextArg);
            }
        }

        $this->validate();

        return $this;
    }
public function parse ( array $ argv ) : self { $ this -> _normalizer = new Normalizer ; \ array_shift ( $ argv ) ; $ argv = $ this -> _normalizer -> normalizeArgs ( $ argv ) ; $ count = \ count ( $ argv ) ; $ literal = false ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { list ( $ arg , $ nextArg ) = [ $ argv [ $ i ] , $ argv [ $ i + 1 ] ?? null ] ; if ( $ arg === '--' ) { $ literal = true ; } elseif ( $ arg [ 0 ] !== '-' || $ literal ) { $ this -> parseArgs ( $ arg ) ; } else { $ i += ( int ) $ this -> parseOptions ( $ arg , $ nextArg ) ; } } $ this -> validate ( ) ; return $ this ; }
Parse the argv input.

@param array $argv The first item is ignored.

@throws \RuntimeException When argument is missing or invalid.

@return self
Parse the argv input .