Skip to content

Commit

Permalink
[CodeQuality] Skip loose compare string on AssertEqualsToSameRector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Dec 25, 2024
1 parent 531ce02 commit 918b33b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\Fixture;

use PHPUnit\Framework\TestCase;

final class SkipLooseCompareString extends TestCase
{
public function test()
{
$this->assertEquals(1, '1');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public function refactor(Node $node): ?Node
$secondArgType = TypeCombinator::removeNull($this->nodeTypeResolver->getNativeType($args[1]->value));

// loose comparison
if ($firstArgType instanceof IntegerType && $secondArgType instanceof FloatType) {
if ($firstArgType instanceof IntegerType && ($secondArgType instanceof FloatType || $secondArgType instanceof StringType)) {
return null;
}

if ($firstArgType instanceof FloatType && $secondArgType instanceof IntegerType) {
if ($firstArgType instanceof FloatType && ($secondArgType instanceof IntegerType || $secondArgType instanceof StringType)) {
return null;
}

Expand Down

0 comments on commit 918b33b

Please sign in to comment.