Skip to content

Commit de29838

Browse files
committed
fix
1 parent f3eabc4 commit de29838

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

rules/Php70/Rector/Ternary/TernaryToNullCoalescingRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Expr;
9+
use PhpParser\Node\Expr\BinaryOp;
910
use PhpParser\Node\Expr\BinaryOp\Coalesce;
1011
use PhpParser\Node\Expr\BinaryOp\Identical;
1112
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
@@ -114,7 +115,7 @@ private function processTernaryWithIsset(Ternary $ternary, Isset_ $isset): ?Coal
114115
return null;
115116
}
116117

117-
if ($ternary->else instanceof Ternary && $this->isTernaryParenthesized($this->file, $ternary->cond, $ternary)) {
118+
if (($ternary->else instanceof Ternary || $ternary->else instanceof BinaryOp) && $this->isTernaryParenthesized($this->file, $ternary->cond, $ternary)) {
118119
$ternary->else->setAttribute(AttributeKey::WRAPPED_IN_PARENTHESES, true);
119120
}
120121

0 commit comments

Comments
 (0)