src/Fixer/Alias/PowToExponentiationFixer.php
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $candidates = $this->findPowCalls($tokens);
        $argumentsAnalyzer = new ArgumentsAnalyzer();

        $numberOfTokensAdded = 0;
        $previousCloseParenthesisIndex = \count($tokens);
        foreach (array_reverse($candidates) as $candidate) {
            // if in the previous iteration(s) tokens were added to the collection and this is done within the tokens
            // indexes of the current candidate than the index of the close ')' of the candidate has moved and so
            // the index needs to be updated
            if ($previousCloseParenthesisIndex < $candidate[2]) {
                $previousCloseParenthesisIndex = $candidate[2];
                $candidate[2] += $numberOfTokensAdded;
            } else {
                $previousCloseParenthesisIndex = $candidate[2];
                $numberOfTokensAdded = 0;
            }

            $arguments = $argumentsAnalyzer->getArguments($tokens, $candidate[1], $candidate[2]);
            if (2 !== \count($arguments)) {
                continue;
            }

            $numberOfTokensAdded += $this->fixPowToExponentiation(
                $tokens,
                $candidate[0], // functionNameIndex,
                $candidate[1], // openParenthesisIndex,
                $candidate[2], // closeParenthesisIndex,
                $arguments
            );
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $candidates = $this->findPowCalls($tokens);
        $argumentsAnalyzer = new ArgumentsAnalyzer();

        $numberOfTokensAdded = 0;
        $previousCloseParenthesisIndex = \count($tokens);
        foreach (array_reverse($candidates) as $candidate) {
            // if in the previous iteration(s) tokens were added to the collection and this is done within the tokens
            // indexes of the current candidate than the index of the close ')' of the candidate has moved and so
            // the index needs to be updated
            if ($previousCloseParenthesisIndex < $candidate[2]) {
                $previousCloseParenthesisIndex = $candidate[2];
                $candidate[2] += $numberOfTokensAdded;
            } else {
                $previousCloseParenthesisIndex = $candidate[2];
                $numberOfTokensAdded = 0;
            }

            $arguments = $argumentsAnalyzer->getArguments($tokens, $candidate[1], $candidate[2]);
            if (2 !== \count($arguments)) {
                continue;
            }

            $numberOfTokensAdded += $this->fixPowToExponentiation(
                $tokens,
                $candidate[0], // functionNameIndex,
                $candidate[1], // openParenthesisIndex,
                $candidate[2], // closeParenthesisIndex,
                $arguments
            );
        }
    }
protected function applyFix ( \ SplFileInfo $ file , Tokens $ tokens ) { $ candidates = $ this -> findPowCalls ( $ tokens ) ; $ argumentsAnalyzer = new ArgumentsAnalyzer ( ) ; $ numberOfTokensAdded = 0 ; $ previousCloseParenthesisIndex = \ count ( $ tokens ) ; foreach ( array_reverse ( $ candidates ) as $ candidate ) { // if in the previous iteration(s) tokens were added to the collection and this is done within the tokens // indexes of the current candidate than the index of the close ')' of the candidate has moved and so // the index needs to be updated if ( $ previousCloseParenthesisIndex < $ candidate [ 2 ] ) { $ previousCloseParenthesisIndex = $ candidate [ 2 ] ; $ candidate [ 2 ] += $ numberOfTokensAdded ; } else { $ previousCloseParenthesisIndex = $ candidate [ 2 ] ; $ numberOfTokensAdded = 0 ; } $ arguments = $ argumentsAnalyzer -> getArguments ( $ tokens , $ candidate [ 1 ] , $ candidate [ 2 ] ) ; if ( 2 !== \ count ( $ arguments ) ) { continue ; } $ numberOfTokensAdded += $ this -> fixPowToExponentiation ( $ tokens , $ candidate [ 0 ] , // functionNameIndex, $ candidate [ 1 ] , // openParenthesisIndex, $ candidate [ 2 ] , // closeParenthesisIndex, $ arguments ) ; } }
{@inheritdoc}
{