Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ public function refactor(Node $node): ?Node
continue;
}

if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames(
$stmt->expr,
// cheap name gate before the costly TestCase type resolution below
if (! $this->isNames(
$stmt->expr->name,
[self::ASSERT_SAME, self::ASSERT_EQUALS, self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS]
)) {
continue;
Expand All @@ -108,10 +109,13 @@ public function refactor(Node $node): ?Node
continue;
}

/** @var FuncCall|Node $secondArgumentValue */
$secondArgumentValue = $stmt->expr->getArgs()[1]
->value;
$callArgs = $stmt->expr->getArgs();
if (! isset($callArgs[1])) {
continue;
}

// cheap preg_match arg gate before the costly TestCase type resolution below
$secondArgumentValue = $callArgs[1]->value;
if (! $secondArgumentValue instanceof FuncCall) {
continue;
}
Expand All @@ -124,6 +128,13 @@ public function refactor(Node $node): ?Node
continue;
}

if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames(
$stmt->expr,
[self::ASSERT_SAME, self::ASSERT_EQUALS, self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS]
)) {
continue;
}

$oldMethodName = $this->getName($stmt->expr->name);
if ($oldMethodName === null) {
continue;
Expand Down
Loading