#
d3ae2ed6 |
| 21-Jul-2024 |
Nikita Popov |
Respect version mode line in pretty printer tests By default parser uses newest supported and pretty printer uses its default version. If version is specified, it's used for both par
Respect version mode line in pretty printer tests By default parser uses newest supported and pretty printer uses its default version. If version is specified, it's used for both parser and printer. Additionally, parserVersion can be used to specify a different version for parser and printer.
show more ...
|
#
a894652a |
| 01-Jul-2024 |
Nikita Popov |
Fix ternary precedence printing The precedence table set the LHS and RHS precedence for the ternary to -1, which is the dummy value used for unary operators. Instead, it should be th
Fix ternary precedence printing The precedence table set the LHS and RHS precedence for the ternary to -1, which is the dummy value used for unary operators. Instead, it should be the same as the operator precedence, as the ternary is non-associative since PHP 8. Fixes #1009.
show more ...
|
#
fcd5934d |
| 27-Feb-2023 |
Nikita Popov |
Prevent merging of consecutive -/+ more thoroughly The unary -/+ or --/++ might not be the direct child. Instead determine this by actually printing the operand and checking whether
Prevent merging of consecutive -/+ more thoroughly The unary -/+ or --/++ might not be the direct child. Instead determine this by actually printing the operand and checking whether it starts with -/+.
show more ...
|
#
cb60eda7 |
| 26-Feb-2023 |
Nikita Popov |
Support yield precedence Since PHP 7.0 yield is a proper expression, so print it with proper precedence. If the pretty printer is configured for older version (non-default), then alw
Support yield precedence Since PHP 7.0 yield is a proper expression, so print it with proper precedence. If the pretty printer is configured for older version (non-default), then always print parentheses. There is an interesting interaction here, in that => is resolved in favor of yield if the yield occurs as part of an array (or outer yield). This kind of bypasses the entire precedence hierarchy and *only* affects yield expressions. For the sake of simplicity this is modeled via normal LHS precedence, because this will only add unnecessary parentheses to a handful of low precedence unary operators. If desired, a special marker for this purpose could be added though.
show more ...
|
#
1cb460ae |
| 26-Feb-2023 |
Nikita Popov |
Handle throw precedence Now that this is an expression, we also need to handle precedence.
|
#
3bd38c5b |
| 25-Feb-2023 |
Nikita Popov |
Properly support prefix operator precedence printing The pretty printer is supposed to produce a minimal-parentheses printing for expressions. However, for prefix operators, we were
Properly support prefix operator precedence printing The pretty printer is supposed to produce a minimal-parentheses printing for expressions. However, for prefix operators, we were failing to do so in ways that are practically meaningful, e.g. $a = yield from $b produced redundant parentheses around the yield from. For prefix operators, the precedence of the direct parent operator is not actually relevant: What matters is the precedence of any infix operator whose LHS it appears on. For example, $a . include $b does not require parentheses, but (include $a) . $b does. To handle this, keep separate track of the parent operator precedence, and a special LHS precedence which is used for unary operator printing only. Because the LHS precedence may not come from the direct parent, we have to pass it down the call stack. And if we do that, we may as well do the same for the parent precedence. This also fixes an integration test failure with php-src, because arrow function precedence was previously not respected (and would be ugly to respect without this change).
show more ...
|
#
d24745dd |
| 26-Feb-2023 |
Nikita Popov |
Respect precedence during clone pretty printing Clone is the prefix operator with the highest operator precedence, but was not treated as an operator at all.
|
#
c218db3e |
| 23-Jul-2022 |
Nikita Popov |
Add additional test case for assignment precedence This is a case where the parentheses around the assignment *are* important.
|
#
7bf63482 |
| 23-Jul-2022 |
Nikita Popov |
Remove inc/dec from precedence map Inc/dec are primitive expressions that only accept a variable operand, rather than a general expression operand.
|
#
eff72eef |
| 30-Sep-2020 |
Nikita Popov |
Fix #718: PrettyPrinter breaks nested ternaries Mark ternary as non-associative operator, as left-associative use is deprecated in PHP 7.4 and removed in PHP 8.0.
|
Revision tags: v4.3.0, v4.2.5, v4.2.4, v4.2.3, v4.2.2, v4.2.1, v4.2.0, v4.1.1, v4.1.0, v4.0.4, v4.0.3, v4.0.2, v4.0.1, v4.0.0, v3.1.5, v4.0.0beta1, v3.1.4 |
|
#
d01fafcb |
| 25-Jan-2018 |
Nikita Popov |
Handle +(++$x) and -(--$x) as well
|
#
94c715d9 |
| 25-Jan-2018 |
Nikita Popov |
Fix pretty printing of -(-$x) and +(+$x) Fixes #459.
|
Revision tags: v4.0.0alpha3, v3.1.3, v4.0.0alpha2, v3.1.2, v4.0.0alpha1, v3.1.1, v3.1.0, v3.0.6, v3.0.5, v3.0.4, v3.0.3, v3.0.2, v3.0.1, v3.0.0, v3.0.0beta2, v3.0.0beta1, v2.1.1, v3.0.0alpha1, v2.1.0, v2.0.1, v2.0.0, v2.0.0beta1 |
|
#
e4b837e0 |
| 02-Oct-2015 |
Nikita Popov |
Split up pretty printer test in stmt/expr The list was getting unweildly. Also improve error message when parsing fails in pretty printer test and extend some tests.
|