public function parse($arguments = null)
    {
        try{
            global $argv;
            $arguments = $arguments ?? $argv;
            $argPointer = 1;
            $parsed = [];
            $this->name = $this->name ?? $arguments[0];
            $this->parseCommand($arguments, $argPointer, $parsed);
            $this->parseArgumentArray($arguments, $argPointer, $parsed);
            $this->maybeShowHelp($parsed);
            $this->validator->validateArguments($this->options, $parsed);
            $this->fillInDefaults($parsed);
            $parsed['__executed'] = $this->name;
            return $parsed;
        } catch (HelpMessageRequestedException $exception) {
            $this->programControl->quit();
        } catch (InvalidArgumentException $exception) {
            print $exception->getMessage() . PHP_EOL;
            $this->programControl->quit();
        }
    }
public function parse($arguments = null)
    {
        try{
            global $argv;
            $arguments = $arguments ?? $argv;
            $argPointer = 1;
            $parsed = [];
            $this->name = $this->name ?? $arguments[0];
            $this->parseCommand($arguments, $argPointer, $parsed);
            $this->parseArgumentArray($arguments, $argPointer, $parsed);
            $this->maybeShowHelp($parsed);
            $this->validator->validateArguments($this->options, $parsed);
            $this->fillInDefaults($parsed);
            $parsed['__executed'] = $this->name;
            return $parsed;
        } catch (HelpMessageRequestedException $exception) {
            $this->programControl->quit();
        } catch (InvalidArgumentException $exception) {
            print $exception->getMessage() . PHP_EOL;
            $this->programControl->quit();
        }
    }
public function parse ( $ arguments = null ) { try { global $ argv ; $ arguments = $ arguments ?? $ argv ; $ argPointer = 1 ; $ parsed = [ ] ; $ this -> name = $ this -> name ?? $ arguments [ 0 ] ; $ this -> parseCommand ( $ arguments , $ argPointer , $ parsed ) ; $ this -> parseArgumentArray ( $ arguments , $ argPointer , $ parsed ) ; $ this -> maybeShowHelp ( $ parsed ) ; $ this -> validator -> validateArguments ( $ this -> options , $ parsed ) ; $ this -> fillInDefaults ( $ parsed ) ; $ parsed [ '__executed' ] = $ this -> name ; return $ parsed ; } catch ( HelpMessageRequestedException $ exception ) { $ this -> programControl -> quit ( ) ; } catch ( InvalidArgumentException $ exception ) { print $ exception -> getMessage ( ) . PHP_EOL ; $ this -> programControl -> quit ( ) ; } }
Parses command line arguments and return a structured array of options and their associated values.

@param array $arguments An optional array of arguments that would be parsed instead of those passed to the CLI.
@return array
@throws InvalidValueException
Parses command line arguments and return a structured array of options and their associated values .