From d8bdab0218c5eb0964338d24a8511b65e9c94fa5 Mon Sep 17 00:00:00 2001 From: Brad <28307684+mad-briller@users.noreply.github.com> Date: Fri, 26 May 2023 10:38:12 +0100 Subject: [PATCH] Microoptimize AssertRuleHelper. --- src/Rules/PHPUnit/AssertRuleHelper.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Rules/PHPUnit/AssertRuleHelper.php b/src/Rules/PHPUnit/AssertRuleHelper.php index 8c288b2..3ad79c0 100644 --- a/src/Rules/PHPUnit/AssertRuleHelper.php +++ b/src/Rules/PHPUnit/AssertRuleHelper.php @@ -16,7 +16,6 @@ class AssertRuleHelper */ public static function isMethodOrStaticCallOnAssert(Node $node, Scope $scope): bool { - $testCaseType = new ObjectType('PHPUnit\Framework\Assert'); if ($node instanceof Node\Expr\MethodCall) { $calledOnType = $scope->getType($node->var); } elseif ($node instanceof Node\Expr\StaticCall) { @@ -45,11 +44,9 @@ public static function isMethodOrStaticCallOnAssert(Node $node, Scope $scope): b return false; } - if (!$testCaseType->isSuperTypeOf($calledOnType)->yes()) { - return false; - } + $testCaseType = new ObjectType('PHPUnit\Framework\Assert'); - return true; + return $testCaseType->isSuperTypeOf($calledOnType)->yes(); } }