diff --git a/rules-tests/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector/Fixture/static_call_assert_count.php.inc b/rules-tests/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector/Fixture/static_call_assert_count.php.inc new file mode 100644 index 00000000..83122ad9 --- /dev/null +++ b/rules-tests/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector/Fixture/static_call_assert_count.php.inc @@ -0,0 +1,37 @@ +items->count()); + } +} + +?> +----- +items); + } +} + +?> diff --git a/rules/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector.php b/rules/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector.php index 489d5169..556cb418 100644 --- a/rules/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector.php +++ b/rules/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector.php @@ -7,6 +7,7 @@ use PhpParser\Node; use PhpParser\Node\Arg; use PhpParser\Node\Expr\MethodCall; +use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Identifier; use Rector\Doctrine\TypedCollections\TypeAnalyzer\CollectionTypeDetector; use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer; @@ -64,14 +65,14 @@ public function test(): void public function getNodeTypes(): array { - return [MethodCall::class]; + return [MethodCall::class, StaticCall::class]; } /** - * @param MethodCall $node + * @param MethodCall|StaticCall $node */ - public function refactor(Node $node): MethodCall|null + public function refactor(Node $node): MethodCall|StaticCall|null { if ($node->isFirstClassCallable()) { return null; @@ -81,7 +82,7 @@ public function refactor(Node $node): MethodCall|null return null; } - if (! $this->testsNodeAnalyzer->isInTestClass($node)) { + if ($node instanceof MethodCall && ! $this->testsNodeAnalyzer->isInTestClass($node)) { return null; }