Skip to content

Commit f8d4f97

Browse files
authored
[CodeQuality] Use ->isBoolean() check on compare boolean and constant bool on UseIdenticalOverEqualWithSameTypeRector (#7415)
1 parent 031f23b commit f8d4f97

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

rules/CodeQuality/Rector/Equal/UseIdenticalOverEqualWithSameTypeRector.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PhpParser\Node\Expr\BinaryOp\NotEqual;
1212
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
1313
use PHPStan\Type\MixedType;
14-
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
1514
use Rector\Rector\AbstractRector;
1615
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1716
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -21,11 +20,6 @@
2120
*/
2221
final class UseIdenticalOverEqualWithSameTypeRector extends AbstractRector
2322
{
24-
public function __construct(
25-
private readonly TypeComparator $typeComparator
26-
) {
27-
}
28-
2923
public function getRuleDefinition(): RuleDefinition
3024
{
3125
return new RuleDefinition(
@@ -91,8 +85,12 @@ public function refactor(Node $node): ?Node
9185
return $this->processIdenticalOrNotIdentical($node);
9286
}
9387

88+
if ($leftStaticType->isBoolean()->yes() && $rightStaticType->isBoolean()->yes()) {
89+
return $this->processIdenticalOrNotIdentical($node);
90+
}
91+
9492
// different types
95-
if (! $this->typeComparator->areTypesEqual($leftStaticType, $rightStaticType)) {
93+
if (! $leftStaticType->equals($rightStaticType)) {
9694
return null;
9795
}
9896

0 commit comments

Comments
 (0)