$precedenceMap
$precedenceMap :
__construct(array $options = array())
Creates a pretty printer instance using the given options.
Supported options:
array | $options | Dictionary of formatting options |
prettyPrint(array<mixed,\PhpParser\Node> $stmts) : string
Pretty prints an array of statements.
array<mixed,\PhpParser\Node> | $stmts | Array of statements |
Pretty printed statements
prettyPrintExpr(\PhpParser\Node\Expr $node) : string
Pretty prints an expression.
\PhpParser\Node\Expr | $node | Expression node |
Pretty printed node
prettyPrintFile(array<mixed,\PhpParser\Node> $stmts) : string
Pretty prints a file of statements (includes the opening <?php tag if it is required).
array<mixed,\PhpParser\Node> | $stmts | Array of statements |
Pretty printed statements
preprocessNodes(array<mixed,\PhpParser\Node> $nodes)
Preprocesses the top-level nodes to initialize pretty printer state.
array<mixed,\PhpParser\Node> | $nodes | Array of nodes |
pStmts(array<mixed,\PhpParser\Node> $nodes, boolean $indent = true) : string
Pretty prints an array of nodes (statements) and indents them optionally.
array<mixed,\PhpParser\Node> | $nodes | Array of nodes |
boolean | $indent | Whether to indent the printed nodes |
Pretty printed statements
p(\PhpParser\Node $node) : string
Pretty prints a node.
\PhpParser\Node | $node | Node to be pretty printed |
Pretty printed node
pInfixOp( $type, \PhpParser\Node $leftNode, $operatorString, \PhpParser\Node $rightNode)
$type | ||
\PhpParser\Node | $leftNode | |
$operatorString | ||
\PhpParser\Node | $rightNode |
pPrefixOp( $type, $operatorString, \PhpParser\Node $node)
$type | ||
$operatorString | ||
\PhpParser\Node | $node |
pPostfixOp( $type, \PhpParser\Node $node, $operatorString)
$type | ||
\PhpParser\Node | $node | |
$operatorString |
pPrec(\PhpParser\Node $node, integer $parentPrecedence, integer $parentAssociativity, integer $childPosition) : string
Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
\PhpParser\Node | $node | Node to pretty print |
integer | $parentPrecedence | Precedence of the parent operator |
integer | $parentAssociativity | Associativity of parent operator (-1 is left, 0 is nonassoc, 1 is right) |
integer | $childPosition | Position of the node relative to the operator (-1 is left, 1 is right) |
The pretty printed node
pImplode(array<mixed,\PhpParser\Node> $nodes, string $glue = '') : string
Pretty prints an array of nodes and implodes the printed values.
array<mixed,\PhpParser\Node> | $nodes | Array of Nodes to be printed |
string | $glue | Character to implode with |
Imploded pretty printed nodes
pCommaSeparated(array<mixed,\PhpParser\Node> $nodes) : string
Pretty prints an array of nodes and implodes the printed values with commas.
array<mixed,\PhpParser\Node> | $nodes | Array of Nodes to be printed |
Comma separated pretty printed nodes
pCommaSeparatedMultiline(array<mixed,\PhpParser\Node> $nodes, boolean $trailingComma) : string
Pretty prints a comma-separated list of nodes in multiline style, including comments.
The result includes a leading newline and one level of indentation (same as pStmts).
array<mixed,\PhpParser\Node> | $nodes | Array of Nodes to be printed |
boolean | $trailingComma | Whether to use a trailing comma |
Comma separated pretty printed nodes in multiline style
pComments(array<mixed,\PhpParser\Comment> $comments) : string
Prints reformatted text of the passed comments.
array<mixed,\PhpParser\Comment> | $comments | List of comments |
Reformatted text of comments