Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;

final class AssertSameConstantArray extends TestCase
{
public function test($result)
public function test(array $result)
{
$expected = [1 => 2];
$this->assertEquals($expected, $result);
Expand All @@ -23,7 +23,7 @@ use PHPUnit\Framework\TestCase;

final class AssertSameConstantArray extends TestCase
{
public function test($result)
public function test(array $result)
{
$expected = [1 => 2];
$this->assertSame($expected, $result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\

final class ClassConstant extends TestCase
{
public function test($result)
public function test(string $result)
{
$this->assertEquals(SimpleConstantList::BOTTOM, $result);
}
Expand All @@ -26,7 +26,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\

final class ClassConstant extends TestCase
{
public function test($result)
public function test(string $result)
{
$this->assertSame(SimpleConstantList::BOTTOM, $result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\

final class Php80Enum extends TestCase
{
public function test($result)
public function test(string $result)
{
$this->assertEquals(SimpleEnum::LEFT, $result);
}
Expand All @@ -24,7 +24,7 @@ use Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertEqualsToSameRector\

final class Php80Enum extends TestCase
{
public function test($result)
public function test(string $result)
{
$this->assertSame(SimpleEnum::LEFT, $result);
}
Expand Down
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 SkipCompareMixed extends TestCase
{
public function test(mixed $result)
{
$this->assertEquals('test', $result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,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 || $secondArgType instanceof MixedType)) {
if ($firstArgType instanceof IntegerType && $secondArgType instanceof FloatType) {
return null;
}

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

Expand All @@ -121,6 +121,11 @@ public function refactor(Node $node): ?Node
)) {
return null;
}

// compare to mixed type is can be anything
if ($secondArgType instanceof MixedType) {
return null;
}
}

$hasChanged = $this->identifierManipulator->renameNodeWithMap($node, self::RENAME_METHODS_MAP);
Expand Down
Loading