File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
rules-tests/CodeQuality/Rector/MethodCall/AssertCountWithZeroToAssertEmptyRector/Fixture
rules/CodeQuality/Rector/MethodCall Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \AssertCountWithZeroToAssertEmptyRector \Fixture ;
4+
5+ final class SkipUnionType extends \PHPUnit \Framework \TestCase
6+ {
7+ public function test ($ something )
8+ {
9+ foreach ([true , false ] as $ value ) {
10+ $ count = (int ) $ value ;
11+ $ this ->assertCount ($ count , $ something );
12+ }
13+ }
14+ }
Original file line number Diff line number Diff line change 88use PhpParser \Node \Expr \MethodCall ;
99use PhpParser \Node \Expr \StaticCall ;
1010use PhpParser \Node \Name ;
11+ use PHPStan \Type \UnionType ;
1112use Rector \PHPUnit \NodeAnalyzer \TestsNodeAnalyzer ;
1213use Rector \Rector \AbstractRector ;
1314use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
@@ -69,6 +70,11 @@ public function refactor(Node $node): MethodCall|StaticCall|null
6970 }
7071
7172 $ type = $ this ->getType ($ node ->getArgs ()[0 ]->value );
73+
74+ if ($ type instanceof UnionType) {
75+ return null ;
76+ }
77+
7278 $ value = ($ type ->getConstantScalarValues ()[0 ] ?? null );
7379 if ($ value === 0 ) {
7480 $ args = $ node ->getArgs ();
You can’t perform that action at this time.
0 commit comments