Skip to content

Commit 0498984

Browse files
committed
📦 Rename enum to ensure that there is no static methods inside, check for static call before checking with enum
As suggested in review comment #482 (comment)
1 parent 35f0032 commit 0498984

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

rules/CodeQuality/Enum/NonAssertPrefixedAssertionMethods.php renamed to rules/CodeQuality/Enum/NonStaticNonAssertPrefixedAssertionMethods.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Rector\PHPUnit\CodeQuality\Enum;
66

7-
final class NonAssertPrefixedAssertionMethods
7+
final class NonStaticNonAssertPrefixedAssertionMethods
88
{
99
/**
1010
* @var string[]

rules/CodeQuality/NodeAnalyser/AssertMethodAnalyzer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use PHPStan\Type\ObjectType;
1212
use Rector\NodeNameResolver\NodeNameResolver;
1313
use Rector\NodeTypeResolver\NodeTypeResolver;
14-
use Rector\PHPUnit\CodeQuality\Enum\NonAssertPrefixedAssertionMethods;
14+
use Rector\PHPUnit\CodeQuality\Enum\NonStaticNonAssertPrefixedAssertionMethods;
1515
use Rector\PHPUnit\Enum\PHPUnitClassName;
1616
use Rector\Reflection\ReflectionResolver;
1717

@@ -35,10 +35,11 @@ public function detectTestCaseCall(MethodCall|StaticCall $call): bool
3535
}
3636

3737
$methodName = $this->nodeNameResolver->getName($call->name);
38-
if (! str_starts_with((string) $methodName, 'assert') && ! in_array(
38+
if (! str_starts_with((string) $methodName, 'assert') && ! ($call instanceof StaticCall && in_array(
3939
$methodName,
40-
NonAssertPrefixedAssertionMethods::ALL
41-
)) {
40+
NonStaticNonAssertPrefixedAssertionMethods::ALL,
41+
true
42+
))) {
4243
return false;
4344
}
4445

0 commit comments

Comments
 (0)