Skip to content

Commit

Permalink
Replace ambiguous wrapped_with_brackets with existing attribute wrapp…
Browse files Browse the repository at this point in the history
…ed_in_parentheses (#6691)
  • Loading branch information
samsonasik authored Jan 22, 2025
1 parent d5d3bcd commit 00ae805
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function refactor(Node $node): ?Node

if ($node->if instanceof Ternary) {
$ternary = $node->if;
$ternary->setAttribute(AttributeKey::KIND, 'wrapped_with_brackets');
$ternary->setAttribute(AttributeKey::KIND, AttributeKey::WRAPPED_IN_PARENTHESES);
$ternary->setAttribute(AttributeKey::ORIGINAL_NODE, null);
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpParser/Printer/BetterStandardPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ protected function pStmt_Declare(Declare_ $declare): string
protected function pExpr_Ternary(Ternary $ternary, int $precedence, int $lhsPrecedence): string
{
$kind = $ternary->getAttribute(AttributeKey::KIND);
if ($kind === 'wrapped_with_brackets') {
if ($kind === AttributeKey::WRAPPED_IN_PARENTHESES) {
$pExprTernary = parent::pExpr_Ternary($ternary, $precedence, $lhsPrecedence);
return '(' . $pExprTernary . ')';
}
Expand Down

0 comments on commit 00ae805

Please sign in to comment.