src/Fixer/FunctionNotation/NoSpacesAfterFunctionNameFixer.php
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $functionyTokens = $this->getFunctionyTokenKinds();
        $languageConstructionTokens = $this->getLanguageConstructionTokenKinds();
        $braceTypes = $this->getBraceAfterVariableKinds();

        foreach ($tokens as $index => $token) {
            // looking for start brace
            if (!$token->equals('(')) {
                continue;
            }

            // last non-whitespace token, can never be `null` always at least PHP open tag before it
            $lastTokenIndex = $tokens->getPrevNonWhitespace($index);

            // check for ternary operator
            $endParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);
            $nextNonWhiteSpace = $tokens->getNextMeaningfulToken($endParenthesisIndex);
            if (
                null !== $nextNonWhiteSpace
                && $tokens[$nextNonWhiteSpace]->equals('?')
                && $tokens[$lastTokenIndex]->isGivenKind($languageConstructionTokens)
            ) {
                continue;
            }

            // check if it is a function call
            if ($tokens[$lastTokenIndex]->isGivenKind($functionyTokens)) {
                $this->fixFunctionCall($tokens, $index);
            } elseif ($tokens[$lastTokenIndex]->isGivenKind(T_STRING)) { // for real function calls or definitions
                $possibleDefinitionIndex = $tokens->getPrevMeaningfulToken($lastTokenIndex);
                if (!$tokens[$possibleDefinitionIndex]->isGivenKind(T_FUNCTION)) {
                    $this->fixFunctionCall($tokens, $index);
                }
            } elseif ($tokens[$lastTokenIndex]->equalsAny($braceTypes)) {
                $block = Tokens::detectBlockType($tokens[$lastTokenIndex]);
                if (
                    Tokens::BLOCK_TYPE_ARRAY_INDEX_CURLY_BRACE === $block['type']
                    || Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE === $block['type']
                    || Tokens::BLOCK_TYPE_INDEX_SQUARE_BRACE === $block['type']
                    || Tokens::BLOCK_TYPE_PARENTHESIS_BRACE === $block['type']
                ) {
                    $this->fixFunctionCall($tokens, $index);
                }
            }
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $functionyTokens = $this->getFunctionyTokenKinds();
        $languageConstructionTokens = $this->getLanguageConstructionTokenKinds();
        $braceTypes = $this->getBraceAfterVariableKinds();

        foreach ($tokens as $index => $token) {
            // looking for start brace
            if (!$token->equals('(')) {
                continue;
            }

            // last non-whitespace token, can never be `null` always at least PHP open tag before it
            $lastTokenIndex = $tokens->getPrevNonWhitespace($index);

            // check for ternary operator
            $endParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);
            $nextNonWhiteSpace = $tokens->getNextMeaningfulToken($endParenthesisIndex);
            if (
                null !== $nextNonWhiteSpace
                && $tokens[$nextNonWhiteSpace]->equals('?')
                && $tokens[$lastTokenIndex]->isGivenKind($languageConstructionTokens)
            ) {
                continue;
            }

            // check if it is a function call
            if ($tokens[$lastTokenIndex]->isGivenKind($functionyTokens)) {
                $this->fixFunctionCall($tokens, $index);
            } elseif ($tokens[$lastTokenIndex]->isGivenKind(T_STRING)) { // for real function calls or definitions
                $possibleDefinitionIndex = $tokens->getPrevMeaningfulToken($lastTokenIndex);
                if (!$tokens[$possibleDefinitionIndex]->isGivenKind(T_FUNCTION)) {
                    $this->fixFunctionCall($tokens, $index);
                }
            } elseif ($tokens[$lastTokenIndex]->equalsAny($braceTypes)) {
                $block = Tokens::detectBlockType($tokens[$lastTokenIndex]);
                if (
                    Tokens::BLOCK_TYPE_ARRAY_INDEX_CURLY_BRACE === $block['type']
                    || Tokens::BLOCK_TYPE_DYNAMIC_VAR_BRACE === $block['type']
                    || Tokens::BLOCK_TYPE_INDEX_SQUARE_BRACE === $block['type']
                    || Tokens::BLOCK_TYPE_PARENTHESIS_BRACE === $block['type']
                ) {
                    $this->fixFunctionCall($tokens, $index);
                }
            }
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { $ functionyTokens = $ this -> getFunctionyTokenKinds ( ) ; $ languageConstructionTokens = $ this -> getLanguageConstructionTokenKinds ( ) ; $ braceTypes = $ this -> getBraceAfterVariableKinds ( ) ; foreach ( $ tokens as $ index => $ token ) { // looking for start brace if ( ! $ token -> equals ( '(' ) ) { continue ; } // last non-whitespace token, can never be `null` always at least PHP open tag before it $ lastTokenIndex = $ tokens -> getPrevNonWhitespace ( $ index ) ; // check for ternary operator $ endParenthesisIndex = $ tokens -> findBlockEnd ( Tokens :: BLOCK_TYPE_PARENTHESIS_BRACE , $ index ) ; $ nextNonWhiteSpace = $ tokens -> getNextMeaningfulToken ( $ endParenthesisIndex ) ; if ( null !== $ nextNonWhiteSpace && $ tokens [ $ nextNonWhiteSpace ] -> equals ( '?' ) && $ tokens [ $ lastTokenIndex ] -> isGivenKind ( $ languageConstructionTokens ) ) { continue ; } // check if it is a function call if ( $ tokens [ $ lastTokenIndex ] -> isGivenKind ( $ functionyTokens ) ) { $ this -> fixFunctionCall ( $ tokens , $ index ) ; } elseif ( $ tokens [ $ lastTokenIndex ] -> isGivenKind ( T_STRING ) ) { // for real function calls or definitions $ possibleDefinitionIndex = $ tokens -> getPrevMeaningfulToken ( $ lastTokenIndex ) ; if ( ! $ tokens [ $ possibleDefinitionIndex ] -> isGivenKind ( T_FUNCTION ) ) { $ this -> fixFunctionCall ( $ tokens , $ index ) ; } } elseif ( $ tokens [ $ lastTokenIndex ] -> equalsAny ( $ braceTypes ) ) { $ block = Tokens :: detectBlockType ( $ tokens [ $ lastTokenIndex ] ) ; if ( Tokens :: BLOCK_TYPE_ARRAY_INDEX_CURLY_BRACE === $ block [ 'type' ] || Tokens :: BLOCK_TYPE_DYNAMIC_VAR_BRACE === $ block [ 'type' ] || Tokens :: BLOCK_TYPE_INDEX_SQUARE_BRACE === $ block [ 'type' ] || Tokens :: BLOCK_TYPE_PARENTHESIS_BRACE === $ block [ 'type' ] ) { $ this -> fixFunctionCall ( $ tokens , $ index ) ; } } } }
{@inheritdoc}
{