File tree Expand file tree Collapse file tree
rules-tests/TypedCollections/Rector/MethodCall/AssertSameCountOnCollectionToAssertCountRector/Fixture
rules/TypedCollections/Rector/MethodCall Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Doctrine \Tests \TypedCollections \Rector \MethodCall \AssertSameCountOnCollectionToAssertCountRector \Fixture ;
4+
5+ use Doctrine \Common \Collections \Collection ;
6+ use Webmozart \Assert \Assert ;
7+
8+ final class StaticCallAssertCount
9+ {
10+ public Collection $ items ;
11+
12+ public function someMethod ()
13+ {
14+ Assert::assertSame (10 , $ this ->items ->count ());
15+ }
16+ }
17+
18+ ?>
19+ -----
20+ <?php
21+
22+ namespace Rector \Doctrine \Tests \TypedCollections \Rector \MethodCall \AssertSameCountOnCollectionToAssertCountRector \Fixture ;
23+
24+ use Doctrine \Common \Collections \Collection ;
25+ use Webmozart \Assert \Assert ;
26+
27+ final class StaticCallAssertCount
28+ {
29+ public Collection $ items ;
30+
31+ public function someMethod ()
32+ {
33+ Assert::assertCount (10 , $ this ->items );
34+ }
35+ }
36+
37+ ?>
Original file line number Diff line number Diff line change 77use PhpParser \Node ;
88use PhpParser \Node \Arg ;
99use PhpParser \Node \Expr \MethodCall ;
10+ use PhpParser \Node \Expr \StaticCall ;
1011use PhpParser \Node \Identifier ;
1112use Rector \Doctrine \TypedCollections \TypeAnalyzer \CollectionTypeDetector ;
1213use Rector \PHPUnit \NodeAnalyzer \TestsNodeAnalyzer ;
@@ -64,14 +65,14 @@ public function test(): void
6465
6566 public function getNodeTypes (): array
6667 {
67- return [MethodCall::class];
68+ return [MethodCall::class, StaticCall::class ];
6869
6970 }
7071
7172 /**
72- * @param MethodCall $node
73+ * @param MethodCall|StaticCall $node
7374 */
74- public function refactor (Node $ node ): MethodCall |null
75+ public function refactor (Node $ node ): MethodCall |StaticCall | null
7576 {
7677 if ($ node ->isFirstClassCallable ()) {
7778 return null ;
@@ -81,7 +82,7 @@ public function refactor(Node $node): MethodCall|null
8182 return null ;
8283 }
8384
84- if (! $ this ->testsNodeAnalyzer ->isInTestClass ($ node )) {
85+ if ($ node instanceof MethodCall && ! $ this ->testsNodeAnalyzer ->isInTestClass ($ node )) {
8586 return null ;
8687 }
8788
You can’t perform that action at this time.
0 commit comments