mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
parent
579f4ce846
commit
94c715d97e
@ -1,7 +1,9 @@
|
||||
Version 3.1.4-dev
|
||||
-----------------
|
||||
|
||||
Nothing yet.
|
||||
### Fixed
|
||||
|
||||
* Fixed pretty printing of `-(-$x)` and `+(+$x)`. (#459)
|
||||
|
||||
Version 3.1.3 (2017-12-26)
|
||||
--------------------------
|
||||
|
@ -374,10 +374,18 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pExpr_UnaryMinus(Expr\UnaryMinus $node) {
|
||||
if ($node->expr instanceof Expr\UnaryMinus) {
|
||||
// Enforce -(-$expr) instead of --$expr
|
||||
return '-(' . $this->p($node->expr) . ')';
|
||||
}
|
||||
return $this->pPrefixOp('Expr_UnaryMinus', '-', $node->expr);
|
||||
}
|
||||
|
||||
protected function pExpr_UnaryPlus(Expr\UnaryPlus $node) {
|
||||
if ($node->expr instanceof Expr\UnaryPlus) {
|
||||
// Enforce +(+$expr) instead of ++$expr
|
||||
return '+(' . $this->p($node->expr) . ')';
|
||||
}
|
||||
return $this->pPrefixOp('Expr_UnaryPlus', '+', $node->expr);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,9 @@ yield from ($a and yield from $b);
|
||||
|
||||
print ($a and print $b);
|
||||
|
||||
-(-$a);
|
||||
+(+$a);
|
||||
|
||||
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
|
||||
// and incdec only work on variables.
|
||||
!$a = $b;
|
||||
@ -70,6 +73,8 @@ $a ** $b ** $c;
|
||||
yield from $a and yield from $b;
|
||||
yield from ($a and yield from $b);
|
||||
print ($a and print $b);
|
||||
-(-$a);
|
||||
+(+$a);
|
||||
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
|
||||
// and incdec only work on variables.
|
||||
!($a = $b);
|
||||
|
Loading…
Reference in New Issue
Block a user