File tree Expand file tree Collapse file tree 5 files changed +26
-8
lines changed
rules-tests/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector/Fixture
rules/CodeQuality/Rector/MethodCall Expand file tree Collapse file tree 5 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;
66
77final class AssertSameConstantArray extends TestCase
88{
9- public function test ($ result )
9+ public function test (array $ result )
1010 {
1111 $ expected = [1 => 2 ];
1212 $ this ->assertEquals ($ expected , $ result );
@@ -23,7 +23,7 @@ use PHPUnit\Framework\TestCase;
2323
2424final class AssertSameConstantArray extends TestCase
2525{
26- public function test ($ result )
26+ public function test (array $ result )
2727 {
2828 $ expected = [1 => 2 ];
2929 $ this ->assertSame ($ expected , $ result );
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\
88
99final class ClassConstant extends TestCase
1010{
11- public function test ($ result )
11+ public function test (string $ result )
1212 {
1313 $ this ->assertEquals (SimpleConstantList::BOTTOM , $ result );
1414 }
@@ -26,7 +26,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\
2626
2727final class ClassConstant extends TestCase
2828{
29- public function test ($ result )
29+ public function test (string $ result )
3030 {
3131 $ this ->assertSame (SimpleConstantList::BOTTOM , $ result );
3232 }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\
77
88final class Php80Enum extends TestCase
99{
10- public function test ($ result )
10+ public function test (string $ result )
1111 {
1212 $ this ->assertEquals (SimpleEnum::LEFT , $ result );
1313 }
@@ -24,7 +24,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\
2424
2525final class Php80Enum extends TestCase
2626{
27- public function test ($ result )
27+ public function test (string $ result )
2828 {
2929 $ this ->assertSame (SimpleEnum::LEFT , $ result );
3030 }
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 SkipCompareMixed extends TestCase
8+ {
9+ public function test (mixed $ result )
10+ {
11+ $ this ->assertEquals ('test ' , $ result );
12+ }
13+ }
Original file line number Diff line number Diff line change @@ -107,11 +107,11 @@ public function refactor(Node $node): ?Node
107107 $ secondArgType = TypeCombinator::removeNull ($ this ->nodeTypeResolver ->getNativeType ($ args [1 ]->value ));
108108
109109 // loose comparison
110- if ($ firstArgType instanceof IntegerType && ( $ secondArgType instanceof FloatType || $ secondArgType instanceof MixedType) ) {
110+ if ($ firstArgType instanceof IntegerType && $ secondArgType instanceof FloatType) {
111111 return null ;
112112 }
113113
114- if ($ firstArgType instanceof FloatType && ( $ secondArgType instanceof IntegerType || $ secondArgType instanceof MixedType) ) {
114+ if ($ firstArgType instanceof FloatType && $ secondArgType instanceof IntegerType) {
115115 return null ;
116116 }
117117
@@ -121,6 +121,11 @@ public function refactor(Node $node): ?Node
121121 )) {
122122 return null ;
123123 }
124+
125+ // compare to mixed type is can be anything
126+ if ($ secondArgType instanceof MixedType) {
127+ return null ;
128+ }
124129 }
125130
126131 $ hasChanged = $ this ->identifierManipulator ->renameNodeWithMap ($ node , self ::RENAME_METHODS_MAP );
You can’t perform that action at this time.
0 commit comments