PhpCsFixer\Fixer\Alias\PowToExponentiationFixer::fix PHP Method

fix() public method

public fix ( SplFileInfo $file, Tokens $tokens )
$file SplFileInfo
$tokens PhpCsFixer\Tokenizer\Tokens
    public function fix(\SplFileInfo $file, Tokens $tokens)
    {
        $candidates = $this->findPowCalls($tokens);
        $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 = $this->getArguments($tokens, $candidate[1], $candidate[2]);
            if (2 !== count($arguments)) {
                continue;
            }
            $numberOfTokensAdded += $this->fixPowToExponentiation($tokens, $candidate[0], $candidate[1], $candidate[2], $arguments);
        }
    }