mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
ac6f221c50
Previously the pretty printer added unnecessary and odd-looking parentheses when several operators with the same precedence were chained: 'a' . 'b' . 'c' . 'd' . 'e' // was printed as 'a' . ('b' . ('c' . ('d' . 'e'))) Another issue reported as part of #39 was that assignments inside closures were wrapped in parentheses: function() { $a = $b; } // was printed as function() { ($a = $b); } This was caused by the automatic precedence handling, which just regarded the closure as an ordinal nested expression. With the new system the $predenceMap of PrettyPrinterAbstract contains both precedence and associativity and there is a new method pPrec() which prints a node taking precedence and associativity into account. For simpler usage there are additional function pInfixOp(), pPrefixOp() and pPostfixOp(). Prints not going through pPrec() do not have any precedence handling (fixing the closure issue). |
||
---|---|---|
.. | ||
Builder | ||
Comment | ||
Lexer | ||
Node | ||
NodeVisitor | ||
PrettyPrinter | ||
Serializer | ||
Unserializer | ||
Autoloader.php | ||
Builder.php | ||
BuilderAbstract.php | ||
BuilderFactory.php | ||
Comment.php | ||
Error.php | ||
Lexer.php | ||
Node.php | ||
NodeAbstract.php | ||
NodeDumper.php | ||
NodeTraverser.php | ||
NodeVisitor.php | ||
NodeVisitorAbstract.php | ||
Parser.php | ||
PrettyPrinterAbstract.php | ||
Serializer.php | ||
Template.php | ||
TemplateLoader.php | ||
Unserializer.php |