protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $inClass = 0;
        $tokenCount = \count($tokens);

        for ($index = 1; $index < $tokenCount - 2; ++$index) {
            if (0 === $inClass && $tokens[$index]->isClassy()) {
                $inClass = 1;
                $index = $tokens->getNextTokenOfKind($index, ['{']);

                continue;
            }

            if (0 !== $inClass) {
                if ($tokens[$index]->equals('{')) {
                    ++$inClass;

                    continue;
                }

                if ($tokens[$index]->equals('}')) {
                    --$inClass;

                    continue;
                }
            }

            if (!$tokens[$index]->isGivenKind(T_STRING)) {
                continue; // wrong type
            }

            $content = $tokens[$index]->getContent();
            if ('__' !== substr($content, 0, 2)) {
                continue; // cheap look ahead
            }

            $name = strtolower($content);

            if (!$this->isMagicMethodName($name)) {
                continue; // method name is not one of the magic ones we can fix
            }

            $nameInCorrectCasing = $this->getMagicMethodNameInCorrectCasing($name);
            if ($nameInCorrectCasing === $content) {
                continue; // method name is already in the correct casing, no fix needed
            }

            if ($this->isFunctionSignature($tokens, $index)) {
                if (0 !== $inClass) {
                    // this is a method definition we want to fix
                    $this->setTokenToCorrectCasing($tokens, $index, $nameInCorrectCasing);
                }

                continue;
            }

            if ($this->isMethodCall($tokens, $index)) {
                $this->setTokenToCorrectCasing($tokens, $index, $nameInCorrectCasing);

                continue;
            }

            if (
                ('__callstatic' === $name || '__set_state' === $name)
                && $this->isStaticMethodCall($tokens, $index)
            ) {
                $this->setTokenToCorrectCasing($tokens, $index, $nameInCorrectCasing);
            }
        }
    }
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
    {
        $inClass = 0;
        $tokenCount = \count($tokens);

        for ($index = 1; $index < $tokenCount - 2; ++$index) {
            if (0 === $inClass && $tokens[$index]->isClassy()) {
                $inClass = 1;
                $index = $tokens->getNextTokenOfKind($index, ['{']);

                continue;
            }

            if (0 !== $inClass) {
                if ($tokens[$index]->equals('{')) {
                    ++$inClass;

                    continue;
                }

                if ($tokens[$index]->equals('}')) {
                    --$inClass;

                    continue;
                }
            }

            if (!$tokens[$index]->isGivenKind(T_STRING)) {
                continue; // wrong type
            }

            $content = $tokens[$index]->getContent();
            if ('__' !== substr($content, 0, 2)) {
                continue; // cheap look ahead
            }

            $name = strtolower($content);

            if (!$this->isMagicMethodName($name)) {
                continue; // method name is not one of the magic ones we can fix
            }

            $nameInCorrectCasing = $this->getMagicMethodNameInCorrectCasing($name);
            if ($nameInCorrectCasing === $content) {
                continue; // method name is already in the correct casing, no fix needed
            }

            if ($this->isFunctionSignature($tokens, $index)) {
                if (0 !== $inClass) {
                    // this is a method definition we want to fix
                    $this->setTokenToCorrectCasing($tokens, $index, $nameInCorrectCasing);
                }

                continue;
            }

            if ($this->isMethodCall($tokens, $index)) {
                $this->setTokenToCorrectCasing($tokens, $index, $nameInCorrectCasing);

                continue;
            }

            if (
                ('__callstatic' === $name || '__set_state' === $name)
                && $this->isStaticMethodCall($tokens, $index)
            ) {
                $this->setTokenToCorrectCasing($tokens, $index, $nameInCorrectCasing);
            }
        }
    }
{@inheritdoc}