Skip to content

Commit db56ff5

Browse files
authored
[CodeQuality] Skip union type on UseIdenticalOverEqualWithSameTypeRector (#7975)
* [CodeQuality] Skip union type on UseIdenticalOverEqualWithSameTypeRector * [CodeQuality] Skip union type on UseIdenticalOverEqualWithSameTypeRector * trigger CI
1 parent c7a0b7d commit db56ff5

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
final class SkipUnion
4+
{
5+
public function run(int|string|float $firstValue, int|string|float $secondValue)
6+
{
7+
return $firstValue == $secondValue;
8+
}
9+
}

‎rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPStan\Type\StringType;
1919
use PHPStan\Type\Type;
2020
use PHPStan\Type\TypeTraverser;
21+
use PHPStan\Type\UnionType;
2122
use Rector\NodeTypeResolver\Node\AttributeKey;
2223
use Rector\Rector\AbstractRector;
2324
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@@ -96,6 +97,10 @@ public function refactor(Node $node): ?Node
9697
return null;
9798
}
9899

100+
if ($normalizedLeftType instanceof UnionType) {
101+
return null;
102+
}
103+
99104
return $this->processIdenticalOrNotIdentical($node);
100105
}
101106

0 commit comments

Comments
 (0)