From 9e3ada3331c6a96dfd6e627202cc295d49eecb3d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 00:49:32 +0200 Subject: [PATCH 1/2] [PHPUnit90] Add cheap method-name gate before TestCase type resolution in AssertRegExpRector --- rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php b/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php index ead35169..241a45f2 100644 --- a/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php +++ b/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php @@ -97,6 +97,14 @@ public function refactor(Node $node): ?Node continue; } + // 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; + } + if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames( $stmt->expr, [self::ASSERT_SAME, self::ASSERT_EQUALS, self::ASSERT_NOT_SAME, self::ASSERT_NOT_EQUALS] From cadb38f0bf70d07d94c7740cb97b541581320de9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 16 Oct 2026 11:18:55 +0200 Subject: [PATCH 2/2] [PHPUnit90] Gate on preg_match arg before TestCase type resolution --- .../Rector/MethodCall/AssertRegExpRector.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php b/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php index 241a45f2..9c740f0d 100644 --- a/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php +++ b/rules/PHPUnit90/Rector/MethodCall/AssertRegExpRector.php @@ -105,21 +105,17 @@ 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] - )) { + if ($stmt->expr->isFirstClassCallable()) { continue; } - if ($stmt->expr->isFirstClassCallable()) { + $callArgs = $stmt->expr->getArgs(); + if (! isset($callArgs[1])) { continue; } - /** @var FuncCall|Node $secondArgumentValue */ - $secondArgumentValue = $stmt->expr->getArgs()[1] - ->value; - + // cheap preg_match arg gate before the costly TestCase type resolution below + $secondArgumentValue = $callArgs[1]->value; if (! $secondArgumentValue instanceof FuncCall) { continue; } @@ -132,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;