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 @@ -64,14 +64,14 @@ public function test(): void
6464
6565 public function getNodeTypes (): array
6666 {
67- return [MethodCall::class];
67+ return [MethodCall::class, Node \ Expr \StaticCall::class ];
6868
6969 }
7070
7171 /**
72- * @param MethodCall $node
72+ * @param MethodCall|Node\Expr\StaticCall $node
7373 */
74- public function refactor (Node $ node ): MethodCall |null
74+ public function refactor (Node $ node ): MethodCall |Node \ Expr \ StaticCall | null
7575 {
7676 if ($ node ->isFirstClassCallable ()) {
7777 return null ;
@@ -81,7 +81,7 @@ public function refactor(Node $node): MethodCall|null
8181 return null ;
8282 }
8383
84- if (! $ this ->testsNodeAnalyzer ->isInTestClass ($ node )) {
84+ if ($ node instanceof MethodCall && ! $ this ->testsNodeAnalyzer ->isInTestClass ($ node )) {
8585 return null ;
8686 }
8787
You can’t perform that action at this time.
0 commit comments