Methods |
public
|
prettyPrint(Node[] $stmts): string
Pretty prints an array of statements.
Pretty prints an array of statements.
Parameters
$stmts |
Array of statements
|
Returns
Pretty printed statements
Implemented by
|
#
|
public
|
prettyPrintExpr(Expr $node): string
Pretty prints an expression.
Pretty prints an expression.
Parameters
Returns
Implemented by
|
#
|
public
|
prettyPrintFile(Node[] $stmts): string
Pretty prints a file of statements (includes the opening <?php tag if it is required).
Pretty prints a file of statements (includes the opening <?php tag if it is required).
Parameters
$stmts |
Array of statements
|
Returns
Pretty printed statements
Implemented by
|
#
|
public
|
printFormatPreserving(Node[] $stmts, Node[] $origStmts, Token[] $origTokens): string
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.
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
$stmts |
Modified AST with links to original AST
|
$origStmts |
Original AST with token offset information
|
$origTokens |
Tokens of the original code
|
Implemented by
|
#
|