protected function mapArgumentsToWords($argumentDefinitions)
    {
        $argumentPositions = array();
        $argumentNumber = 0;
        $previousWord = null;
        $argumentNames = array_keys($argumentDefinitions);

        // Build a list of option values to filter out
        $optionsWithArgs = $this->getOptionWordsWithValues();

        foreach ($this->context->getWords() as $wordIndex => $word) {
            // Skip program name, command name, options, and option values
            if ($wordIndex < 2
                || ($word && '-' === $word[0])
                || in_array($previousWord, $optionsWithArgs)) {
                $previousWord = $word;
                continue;
            } else {
                $previousWord = $word;
            }

            // If argument n exists, pair that argument's name with the current word
            if (isset($argumentNames[$argumentNumber])) {
                $argumentPositions[$wordIndex] = $argumentNames[$argumentNumber];
            }

            $argumentNumber++;
        }

        return $argumentPositions;
    }
protected function mapArgumentsToWords($argumentDefinitions)
    {
        $argumentPositions = array();
        $argumentNumber = 0;
        $previousWord = null;
        $argumentNames = array_keys($argumentDefinitions);

        // Build a list of option values to filter out
        $optionsWithArgs = $this->getOptionWordsWithValues();

        foreach ($this->context->getWords() as $wordIndex => $word) {
            // Skip program name, command name, options, and option values
            if ($wordIndex < 2
                || ($word && '-' === $word[0])
                || in_array($previousWord, $optionsWithArgs)) {
                $previousWord = $word;
                continue;
            } else {
                $previousWord = $word;
            }

            // If argument n exists, pair that argument's name with the current word
            if (isset($argumentNames[$argumentNumber])) {
                $argumentPositions[$wordIndex] = $argumentNames[$argumentNumber];
            }

            $argumentNumber++;
        }

        return $argumentPositions;
    }
protected function mapArgumentsToWords ( $ argumentDefinitions ) { $ argumentPositions = array ( ) ; $ argumentNumber = 0 ; $ previousWord = null ; $ argumentNames = array_keys ( $ argumentDefinitions ) ; // Build a list of option values to filter out $ optionsWithArgs = $ this -> getOptionWordsWithValues ( ) ; foreach ( $ this -> context -> getWords ( ) as $ wordIndex => $ word ) { // Skip program name, command name, options, and option values if ( $ wordIndex < 2 || ( $ word && '-' === $ word [ 0 ] ) || in_array ( $ previousWord , $ optionsWithArgs ) ) { $ previousWord = $ word ; continue ; } else { $ previousWord = $ word ; } // If argument n exists, pair that argument's name with the current word if ( isset ( $ argumentNames [ $ argumentNumber ] ) ) { $ argumentPositions [ $ wordIndex ] = $ argumentNames [ $ argumentNumber ] ; } $ argumentNumber ++ ; } return $ argumentPositions ; }
Step through the command line to determine which word positions represent which argument values

The word indexes of argument values are found by eliminating words that are known to not be arguments (options,
option values, and command names). Any word that doesn't match for elimination is assumed to be an argument value,

@param InputArgument[] $argumentDefinitions
@return array as [argument name => word index on command line]
Step through the command line to determine which word positions represent which argument values