File tree Expand file tree Collapse file tree 3 files changed +51
-21
lines changed
rules/CodeQuality/Rector/MethodCall
tests/Issues/AssertEqualsSame/Fixture Expand file tree Collapse file tree 3 files changed +51
-21
lines changed Original file line number Diff line number Diff line change 1111use PhpParser \Node \Expr \MethodCall ;
1212use PhpParser \Node \Expr \StaticCall ;
1313use PhpParser \Node \Scalar \InterpolatedString ;
14+ use PhpParser \Node \Scalar \String_ ;
1415use PHPStan \Type \BooleanType ;
1516use PHPStan \Type \Constant \ConstantArrayType ;
1617use PHPStan \Type \Constant \ConstantBooleanType ;
@@ -142,7 +143,11 @@ private function shouldSkipLooseComparison(array $args): bool
142143 }
143144
144145 // can happen with magic process
145- return $ secondArgType instanceof NeverType;
146+ if ($ secondArgType instanceof NeverType) {
147+ return true ;
148+ }
149+
150+ return $ args [0 ]->value instanceof String_ && is_numeric ($ args [0 ]->value ->value );
146151 }
147152
148153 private function shouldSkipConstantArrayType (Expr $ expr ): bool
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \PHPUnit \Tests \Issues \AssertEqualsSame ;
6+
7+ use PHPUnit \Framework \TestCase ;
8+
9+ class AssertEquals extends TestCase
10+ {
11+ public function test ()
12+ {
13+ $ this ->assertEquals (123 , $ this ->getOrderId ());
14+ }
15+
16+ private function getOrderId (): string
17+ {
18+ return '0000000000000000000123 ' ;
19+ }
20+ }
21+
22+ ?>
23+ -----
24+ <?php
25+
26+ declare (strict_types=1 );
27+
28+ namespace Rector \PHPUnit \Tests \Issues \AssertEqualsSame ;
29+
30+ use PHPUnit \Framework \TestCase ;
31+
32+ class AssertEquals extends TestCase
33+ {
34+ public function test ()
35+ {
36+ $ this ->assertEquals ('123 ' , $ this ->getOrderId ());
37+ }
38+
39+ private function getOrderId (): string
40+ {
41+ return '0000000000000000000123 ' ;
42+ }
43+ }
44+
45+ ?>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments