function PrettyPrinter::printFormatPreserving
Perform a format-preserving pretty print of an AST.
The format preservation is best effort. For some changes to the AST the formatting will not be preserved (at least not locally).
In order to use this method a number of prerequisites must be satisfied:
- The startTokenPos and endTokenPos attributes in the lexer must be enabled.
- The CloningVisitor must be run on the AST prior to modification.
- The original tokens must be provided, using the getTokens() method on the lexer.
Parameters
Node[] $stmts Modified AST with links to original AST:
Node[] $origStmts Original AST with token offset information:
Token[] $origTokens Tokens of the original code:
1 method overrides PrettyPrinter::printFormatPreserving()
- PrettyPrinterAbstract::printFormatPreserving in vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinterAbstract.php - Perform a format-preserving pretty print of an AST.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ PrettyPrinter.php, line 50
Class
Namespace
PhpParserCode
public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) : string;