Stecman\Component\Symfony\Console\BashCompletion\CompletionHandler::mapArgumentsToWords PHP Метод

mapArgumentsToWords() защищенный Метод

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,
protected mapArgumentsToWords ( Symfony\Component\Console\Input\InputArgument[] $argumentDefinitions ) : array
$argumentDefinitions Symfony\Component\Console\Input\InputArgument[]
Результат array as [argument name => word index on command line]
    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;
    }