Skip to content

Commit

Permalink
Use insertAt instead of insertSlices
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Oct 6, 2021
1 parent fad7768 commit 168a345
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php
Expand Up @@ -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;
}

Expand Down Expand Up @@ -152,6 +154,6 @@ private function fixGetClassCall(Tokens $tokens, int $index, int $braceOpenIndex
}

$tokens->clearAt($index);
$tokens->insertSlices([$index => $replacements]);
$tokens->insertAt($index, $replacements);
}
}

0 comments on commit 168a345

Please sign in to comment.