mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2025-01-21 21:01:15 +01:00
Fix "print" pretty-printing
Precedence was previously ignored.
This commit is contained in:
parent
ab80054e97
commit
338bc1f8e7
@ -316,6 +316,10 @@ class Standard extends PrettyPrinterAbstract
|
|||||||
return $this->pPrefixOp('Expr_YieldFrom', 'yield from ', $node->expr);
|
return $this->pPrefixOp('Expr_YieldFrom', 'yield from ', $node->expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function pExpr_Print(Expr\Print_ $node) {
|
||||||
|
return $this->pPrefixOp('Expr_Print', 'print ', $node->expr);
|
||||||
|
}
|
||||||
|
|
||||||
// Casts
|
// Casts
|
||||||
|
|
||||||
public function pExpr_Cast_Int(Cast\Int_ $node) {
|
public function pExpr_Cast_Int(Cast\Int_ $node) {
|
||||||
@ -376,10 +380,6 @@ class Standard extends PrettyPrinterAbstract
|
|||||||
return 'isset(' . $this->pCommaSeparated($node->vars) . ')';
|
return 'isset(' . $this->pCommaSeparated($node->vars) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pExpr_Print(Expr\Print_ $node) {
|
|
||||||
return 'print ' . $this->p($node->expr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function pExpr_Eval(Expr\Eval_ $node) {
|
public function pExpr_Eval(Expr\Eval_ $node) {
|
||||||
return 'eval(' . $this->p($node->expr) . ')';
|
return 'eval(' . $this->p($node->expr) . ')';
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ abstract class PrettyPrinterAbstract
|
|||||||
'Expr_AssignOp_ShiftRight' => array(160, 1),
|
'Expr_AssignOp_ShiftRight' => array(160, 1),
|
||||||
'Expr_AssignOp_Pow' => array(160, 1),
|
'Expr_AssignOp_Pow' => array(160, 1),
|
||||||
'Expr_YieldFrom' => array(165, 1),
|
'Expr_YieldFrom' => array(165, 1),
|
||||||
|
'Expr_Print' => array(168, 1),
|
||||||
'Expr_BinaryOp_LogicalAnd' => array(170, -1),
|
'Expr_BinaryOp_LogicalAnd' => array(170, -1),
|
||||||
'Expr_BinaryOp_LogicalXor' => array(180, -1),
|
'Expr_BinaryOp_LogicalXor' => array(180, -1),
|
||||||
'Expr_BinaryOp_LogicalOr' => array(190, -1),
|
'Expr_BinaryOp_LogicalOr' => array(190, -1),
|
||||||
|
@ -36,6 +36,8 @@ $a ** $b ** $c;
|
|||||||
yield from $a and yield from $b;
|
yield from $a and yield from $b;
|
||||||
yield from ($a and yield from $b);
|
yield from ($a and yield from $b);
|
||||||
|
|
||||||
|
print ($a and print $b);
|
||||||
|
|
||||||
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
|
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
|
||||||
// and incdec only work on variables.
|
// and incdec only work on variables.
|
||||||
!$a = $b;
|
!$a = $b;
|
||||||
@ -67,6 +69,7 @@ $a ** $b ** $c;
|
|||||||
-1 ** 2;
|
-1 ** 2;
|
||||||
yield from $a and yield from $b;
|
yield from $a and yield from $b;
|
||||||
yield from ($a and yield from $b);
|
yield from ($a and yield from $b);
|
||||||
|
print ($a and print $b);
|
||||||
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
|
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
|
||||||
// and incdec only work on variables.
|
// and incdec only work on variables.
|
||||||
!($a = $b);
|
!($a = $b);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user