diff --git a/src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php b/src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php index 51c3144d8e1..638b1ffb3ee 100644 --- a/src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php +++ b/src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php @@ -83,12 +83,14 @@ public function isRisky(): bool */ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { + $functionsAnalyzer = new FunctionsAnalyzer(); + for ($index = $tokens->count() - 1; $index > 0; --$index) { if (!$tokens[$index]->equals([T_STRING, 'get_class'], false)) { continue; } - if (!(new FunctionsAnalyzer())->isGlobalFunctionCall($tokens, $index)) { + if (!$functionsAnalyzer->isGlobalFunctionCall($tokens, $index)) { continue; } @@ -152,6 +154,6 @@ private function fixGetClassCall(Tokens $tokens, int $index, int $braceOpenIndex } $tokens->clearAt($index); - $tokens->insertSlices([$index => $replacements]); + $tokens->insertAt($index, $replacements); } }