Skip to content

Commit 918b33b

Browse files
authored
[CodeQuality] Skip loose compare string on AssertEqualsToSameRector (#435)
1 parent 531ce02 commit 918b33b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class SkipLooseCompareString extends TestCase
8+
{
9+
public function test()
10+
{
11+
$this->assertEquals(1, '1');
12+
}
13+
}

rules/CodeQuality/Rector/MethodCall/AssertEqualsToSameRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ public function refactor(Node $node): ?Node
108108
$secondArgType = TypeCombinator::removeNull($this->nodeTypeResolver->getNativeType($args[1]->value));
109109

110110
// loose comparison
111-
if ($firstArgType instanceof IntegerType && $secondArgType instanceof FloatType) {
111+
if ($firstArgType instanceof IntegerType && ($secondArgType instanceof FloatType || $secondArgType instanceof StringType)) {
112112
return null;
113113
}
114114

115-
if ($firstArgType instanceof FloatType && $secondArgType instanceof IntegerType) {
115+
if ($firstArgType instanceof FloatType && ($secondArgType instanceof IntegerType || $secondArgType instanceof StringType)) {
116116
return null;
117117
}
118118

0 commit comments

Comments
 (0)