File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture
rules/CodeQuality/Rector/MethodCall Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \AssertEqualsToSameRector \Fixture ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+
7+ final class DynamicBool extends TestCase
8+ {
9+ public function testIsHeaderLine (string $ line , bool $ expected ): void
10+ {
11+ $ this ->assertEquals ($ expected , $ this ->returnsBool ($ line ));
12+ }
13+
14+ public function returnsBool (): bool {
15+ return rand (0 ,1 ) ? true : false ;
16+ }
17+ }
18+
19+ ?>
20+ -----
21+ <?php
22+
23+ namespace Rector \PHPUnit \Tests \CodeQuality \Rector \MethodCall \AssertEqualsToSameRector \Fixture ;
24+
25+ use PHPUnit \Framework \TestCase ;
26+
27+ final class DynamicBool extends TestCase
28+ {
29+ public function testIsHeaderLine (string $ line , bool $ expected ): void
30+ {
31+ $ this ->assertSame ($ expected , $ this ->returnsBool ($ line ));
32+ }
33+
34+ public function returnsBool (): bool {
35+ return rand (0 ,1 ) ? true : false ;
36+ }
37+ }
38+
39+ ?>
Original file line number Diff line number Diff line change 1010use PhpParser \Node \Expr \MethodCall ;
1111use PhpParser \Node \Expr \StaticCall ;
1212use PhpParser \Node \Scalar \InterpolatedString ;
13+ use PHPStan \Type \BooleanType ;
1314use PHPStan \Type \Constant \ConstantArrayType ;
15+ use PHPStan \Type \Constant \ConstantBooleanType ;
1416use PHPStan \Type \FloatType ;
1517use PHPStan \Type \IntegerType ;
1618use PHPStan \Type \StringType ;
@@ -143,7 +145,11 @@ private function isScalarType(Type $valueNodeType): bool
143145 }
144146 }
145147
146- return false ;
148+ if ($ valueNodeType instanceof ConstantBooleanType) {
149+ return false ;
150+ }
151+
152+ return $ valueNodeType instanceof BooleanType;
147153 }
148154
149155 private function isScalarOrEnumValue (Expr $ expr ): bool
You can’t perform that action at this time.
0 commit comments