Constants |
public
PhpParser |
public
PhpParser |
public
PhpParser |
public
PhpParser |
public
PhpParser |
public
PhpParser |
public
PhpParser |
Methods |
public
__construct
(
array
$options
=
[
]
) Creates a pretty printer instance using the given options. Supported options:
|
public
prettyPrint
(
array
$stmts
) :
string
Pretty prints an array of statements.
|
public
prettyPrintExpr
(
PhpParser Pretty prints an expression.
|
public
prettyPrintFile
(
array
$stmts
) :
string
Pretty prints a file of statements (includes the opening <?php tag if it is required).
|
public
printFormatPreserving
(
array
$stmts
,
array
$origStmts
,
array
$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 In order to use this method a number of prerequisites must be satisfied:
|
Properties |
protected
$canUseSemicolonNamespaces
|
protected
$docStringEndToken
|
protected $emptyListInsertionMap |
protected
$fixupMap
|
protected
$indentLevel
|
protected
$insertionMap
|
protected
$labelCharMap
|
protected
$listInsertionMap
|
protected
$modifierChangeMap
|
protected
$nl
|
protected
$nodeListDiffer
|
protected
$options
|
protected
$origTokens
|
protected $precedenceMap |
protected
$removalMap
|
Methods |
protected
callLhsRequiresParens
(
PhpParser Determines whether the LHS of a call must be wrapped in parenthesis.
|
protected
dereferenceLhsRequiresParens
(
PhpParser Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis.
|
protected
handleMagicTokens
(
string
$str
) :
string
Handles (and removes) no-indent and doc-string-end tokens.
|
protected
indent
() Increase indentation level. |
protected initializeEmptyListInsertionMap () |
protected
initializeFixupMap
() Lazily initializes fixup map. The fixup map is used to determine whether a certain subnode of a certain node may require |
protected initializeInsertionMap () |
protected
initializeLabelCharMap
() Lazily initializes label char map. The label char map determines whether a certain character may occur in a label. |
protected initializeListInsertionMap () |
protected initializeModifierChangeMap () |
protected
initializeNodeListDiffer
() Lazily initializes node list differ. The node list differ is used to determine differences between two array subnodes. |
protected
initializeRemovalMap
() Lazily initializes the removal map. The removal map is used to determine which additional tokens should be removed when a |
protected
isMultiline
(
array
$nodes
) :
bool
Determine whether a list of nodes uses multiline formatting.
|
protected
outdent
() Decrease indentation level. |
protected
p
(
PhpParser Pretty prints a node. This method also handles formatting preservation for nodes.
|
protected
pArray
(
array
$nodes
,
array
$origNodes
,
int
$pos
,
int
$indentAdjustment
,
string
$parentNodeType
,
string
$subNodeName
,
$fixup
) Perform a format-preserving pretty print of an array.
|
protected
pCommaSeparated
(
array
$nodes
) :
string
Pretty prints an array of nodes and implodes the printed values with commas.
|
protected
pCommaSeparatedMultiline
(
array
$nodes
,
bool
$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).
|
protected
pComments
(
array
$comments
) :
string
Prints reformatted text of the passed comments.
|
protected
pFallback
(
PhpParser |
protected
pFixup
(
int
$fixup
,
PhpParser Print node with fixups. Fixups here refer to the addition of extra parentheses, braces or other characters, that
|
protected
pImplode
(
array
$nodes
,
string
$glue
=
''
) :
string
Pretty prints an array of nodes and implodes the printed values.
|
protected
pInfixOp
(
string
$class
,
PhpParser Pretty-print an infix operation while taking precedence into account.
|
protected
pModifiers
(
int
$modifiers
) Print modifiers, including trailing whitespace.
|
protected
pPostfixOp
(
string
$class
,
PhpParser Pretty-print a postfix operation while taking precedence into account.
|
protected
pPrec
(
PhpParser Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
|
protected
pPrefixOp
(
string
$class
,
string
$operatorString
,
PhpParser Pretty-print a prefix operation while taking precedence into account.
|
protected
preprocessNodes
(
array
$nodes
) Preprocesses the top-level nodes to initialize pretty printer state.
|
protected
pStmts
(
array
$nodes
,
bool
$indent
=
true
) :
string
Pretty prints an array of nodes (statements) and indents them optionally.
|
protected
resetState
() Reset pretty printing state. |
protected
safeAppend
(
string
$str
,
string
$append
) Appends to a string, ensuring whitespace between label characters. Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x".
|
protected
setIndentLevel
(
int
$level
) Set indentation level
|