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(); } }