PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer::fixSpace PHP Method

fixSpace() public method

Method to insert space after comma and remove space before comma.
public fixSpace ( Tokens $tokens, integer $index )
$tokens PhpCsFixer\Tokenizer\Tokens
$index integer
    public function fixSpace(Tokens $tokens, $index)
    {
        // remove space before comma if exist
        if ($tokens[$index - 1]->isWhitespace()) {
            $prevIndex = $tokens->getPrevNonWhitespace($index - 1);
            if (!$tokens[$prevIndex]->equalsAny(array(',', array(T_END_HEREDOC)))) {
                $tokens[$index - 1]->clear();
            }
        }
        $nextToken = $tokens[$index + 1];
        // Two cases for fix space after comma (exclude multiline comments)
        //  1) multiple spaces after comma
        //  2) no space after comma
        if ($nextToken->isWhitespace()) {
            if ($this->isCommentLastLineToken($tokens, $index + 2)) {
                return;
            }
            $newContent = ltrim($nextToken->getContent(), " \t");
            if ('' === $newContent) {
                $newContent = ' ';
            }
            $nextToken->setContent($newContent);
            return;
        }
        if (!$this->isCommentLastLineToken($tokens, $index + 1)) {
            $tokens->insertAt($index + 1, new Token(array(T_WHITESPACE, ' ')));
        }
    }