Skip to content

Commit

Permalink
Add the AssertEqualsFixer::isMethodCall() method
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Feb 20, 2024
1 parent b25a74d commit c3e3947
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Fixer/AssertEqualsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

$name = $tokens[$index]->getContent();

if (
!isset($this->mapper[$name])
|| !$tokens[$index - 1]->isGivenKind(T_OBJECT_OPERATOR)
|| !$tokens[$index + 1]->equals('(')
) {
if (!isset($this->mapper[$name]) || !$this->isMethodCall($index, $tokens)) {
continue;
}

Expand All @@ -87,4 +83,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$tokens->offsetSet($index, new Token([T_STRING, $this->mapper[$name]]));
}
}

private function isMethodCall(int $index, Tokens $tokens): bool
{
return $tokens[$index - 1]->isGivenKind([T_OBJECT_OPERATOR, T_PAAMAYIM_NEKUDOTAYIM]) && $tokens[$index + 1]->equals('(');
}
}

0 comments on commit c3e3947

Please sign in to comment.