Skip to content

Commit 58ea9b1

Browse files
authored
[CodeQuality] Drop redundant bool cast under negation in UnnecessaryTernaryExpressionRector (#9024)
1 parent 1f0a888 commit 58ea9b1

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

‎rules-tests/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector/Fixture/fixture3.php.inc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Fixture3
4646
public function go(): bool
4747
{
4848
$order = $someQueryBuilder->getQuery()->getOneOrNullResult();
49-
return !(bool) $order;
49+
return !$order;
5050
}
5151

5252
public function boolAlready(): bool

‎rules/CodeQuality/Rector/Ternary/UnnecessaryTernaryExpressionRector.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ private function processFalseIfExpressionWithTrueElseExpression(Expr $expr): Exp
128128
return new Bool_($expr->expr);
129129
}
130130

131-
$exprType = $this->getType($expr);
132-
if ($exprType->isBoolean()->yes()) {
133-
return new BooleanNot($expr);
134-
}
135-
136-
return new BooleanNot(new Bool_($expr));
131+
return new BooleanNot($expr);
137132
}
138133
}

0 commit comments

Comments
 (0)