From 168a3455ede9b5e7c002bf87cebd799f1d7e0f90 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 6 Oct 2021 11:53:59 +0800 Subject: [PATCH] Use `insertAt` instead of `insertSlices` --- src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); } }