Documentation

Standard extends PrettyPrinterAbstract
in package

Table of Contents

Constants

FIXUP_BRACED_NAME  = 6
FIXUP_CALL_LHS  = 3
FIXUP_DEREF_LHS  = 4
FIXUP_ENCAPSED  = 8
FIXUP_NEW  = 9
FIXUP_PREC_LEFT  = 0
FIXUP_PREC_RIGHT  = 1
FIXUP_PREC_UNARY  = 2
FIXUP_STATIC_DEREF_LHS  = 5
FIXUP_VAR_BRACED_NAME  = 7
MAX_PRECEDENCE  = 1000

Properties

$canUseSemicolonNamespaces  : bool
$docStringEndToken  : string|null
$emptyListInsertionMap  : array<string, array{: int|string|null, : string, : string}>
$fixupMap  : array<string, array<string, int>>
$indentLevel  : int
$insertionMap  : array<string, array{: int|string|null, : bool, : string|null, : string|null}>
$labelCharMap  : array<string, bool>
$listInsertionMap  : array<string, string>
$modifierChangeMap  : array<string, array{: string, : int}>
$newline  : string
$nl  : string
$nodeListDiffer  : Differ<string|int, Node>
$origTokens  : TokenStream|null
$phpVersion  : PhpVersion
$precedenceMap  : array<class-string, array{: int, : int, : int}>
$removalMap  : array<string, array{left?: int|string, right?: int|string}>
$shortArraySyntax  : bool

Methods

__construct()  : mixed
Creates a pretty printer instance using the given options.
prettyPrint()  : string
Pretty prints an array of statements.
prettyPrintExpr()  : string
Pretty prints an expression.
prettyPrintFile()  : string
Pretty prints a file of statements (includes the opening <?php tag if it is required).
printFormatPreserving()  : string
Perform a format-preserving pretty print of an AST.
callLhsRequiresParens()  : bool
Determines whether the LHS of a call must be wrapped in parenthesis.
containsEndLabel()  : bool
dereferenceLhsRequiresParens()  : bool
Determines whether the LHS of an array/object operation must be wrapped in parentheses.
encapsedContainsEndLabel()  : bool
escapeString()  : string
handleMagicTokens()  : string
Handles (and removes) doc-string-end tokens.
hasNodeWithComments()  : bool
indent()  : void
Increase indentation level.
initializeEmptyListInsertionMap()  : void
initializeFixupMap()  : void
Lazily initializes fixup map.
initializeInsertionMap()  : void
initializeLabelCharMap()  : void
Lazily initializes label char map.
initializeListInsertionMap()  : void
initializeModifierChangeMap()  : void
initializeNodeListDiffer()  : void
Lazily initializes node list differ.
initializeRemovalMap()  : void
Lazily initializes the removal map.
isMultiline()  : bool
Determine whether a list of nodes uses multiline formatting.
newOperandRequiresParens()  : bool
Determines whether an expression used in "new" or "instanceof" requires parentheses.
outdent()  : void
Decrease indentation level.
p()  : string
Pretty prints a node.
pArg()  : string
pArray()  : null|string
Perform a format-preserving pretty print of an array.
pArrayItem()  : string
pAttrGroups()  : string
pAttribute()  : string
pAttributeGroup()  : string
pCallLhs()  : string
pClassCommon()  : string
pClosureUse()  : string
pCommaSeparated()  : string
Pretty prints an array of nodes and implodes the printed values with commas.
pCommaSeparatedMultiline()  : string
Pretty prints a comma-separated list of nodes in multiline style, including comments.
pComments()  : string
Prints reformatted text of the passed comments.
pConst()  : string
pDeclareItem()  : string
pDereferenceLhs()  : string
pEncapsList()  : string
pExpr_Array()  : string
pExpr_ArrayDimFetch()  : string
pExpr_ArrowFunction()  : string
pExpr_Assign()  : string
pExpr_AssignOp_BitwiseAnd()  : string
pExpr_AssignOp_BitwiseOr()  : string
pExpr_AssignOp_BitwiseXor()  : string
pExpr_AssignOp_Coalesce()  : string
pExpr_AssignOp_Concat()  : string
pExpr_AssignOp_Div()  : string
pExpr_AssignOp_Minus()  : string
pExpr_AssignOp_Mod()  : string
pExpr_AssignOp_Mul()  : string
pExpr_AssignOp_Plus()  : string
pExpr_AssignOp_Pow()  : string
pExpr_AssignOp_ShiftLeft()  : string
pExpr_AssignOp_ShiftRight()  : string
pExpr_AssignRef()  : string
pExpr_BinaryOp_BitwiseAnd()  : string
pExpr_BinaryOp_BitwiseOr()  : string
pExpr_BinaryOp_BitwiseXor()  : string
pExpr_BinaryOp_BooleanAnd()  : string
pExpr_BinaryOp_BooleanOr()  : string
pExpr_BinaryOp_Coalesce()  : string
pExpr_BinaryOp_Concat()  : string
pExpr_BinaryOp_Div()  : string
pExpr_BinaryOp_Equal()  : string
pExpr_BinaryOp_Greater()  : string
pExpr_BinaryOp_GreaterOrEqual()  : string
pExpr_BinaryOp_Identical()  : string
pExpr_BinaryOp_LogicalAnd()  : string
pExpr_BinaryOp_LogicalOr()  : string
pExpr_BinaryOp_LogicalXor()  : string
pExpr_BinaryOp_Minus()  : string
pExpr_BinaryOp_Mod()  : string
pExpr_BinaryOp_Mul()  : string
pExpr_BinaryOp_NotEqual()  : string
pExpr_BinaryOp_NotIdentical()  : string
pExpr_BinaryOp_Plus()  : string
pExpr_BinaryOp_Pow()  : string
pExpr_BinaryOp_ShiftLeft()  : string
pExpr_BinaryOp_ShiftRight()  : string
pExpr_BinaryOp_Smaller()  : string
pExpr_BinaryOp_SmallerOrEqual()  : string
pExpr_BinaryOp_Spaceship()  : string
pExpr_BitwiseNot()  : string
pExpr_BooleanNot()  : string
pExpr_Cast_Array()  : string
pExpr_Cast_Bool()  : string
pExpr_Cast_Double()  : string
pExpr_Cast_Int()  : string
pExpr_Cast_Object()  : string
pExpr_Cast_String()  : string
pExpr_Cast_Unset()  : string
pExpr_ClassConstFetch()  : string
pExpr_Clone()  : string
pExpr_Closure()  : string
pExpr_ConstFetch()  : string
pExpr_Empty()  : string
pExpr_Error()  : string
pExpr_ErrorSuppress()  : string
pExpr_Eval()  : string
pExpr_Exit()  : string
pExpr_FuncCall()  : string
pExpr_Include()  : string
pExpr_Instanceof()  : string
pExpr_Isset()  : string
pExpr_List()  : string
pExpr_Match()  : string
pExpr_MethodCall()  : string
pExpr_New()  : string
pExpr_NullsafeMethodCall()  : string
pExpr_NullsafePropertyFetch()  : string
pExpr_PostDec()  : string
pExpr_PostInc()  : string
pExpr_PreDec()  : string
pExpr_PreInc()  : string
pExpr_Print()  : string
pExpr_PropertyFetch()  : string
pExpr_ShellExec()  : string
pExpr_StaticCall()  : string
pExpr_StaticPropertyFetch()  : string
pExpr_Ternary()  : string
pExpr_Throw()  : string
pExpr_UnaryMinus()  : string
pExpr_UnaryPlus()  : string
pExpr_Variable()  : string
pExpr_Yield()  : string
pExpr_YieldFrom()  : string
pFallback()  : string
pFixup()  : string
Print node with fixups.
pIdentifier()  : string
pImplode()  : string
Pretty prints an array of nodes and implodes the printed values.
pInfixOp()  : string
Pretty-print an infix operation while taking precedence into account.
pIntersectionType()  : string
pKey()  : string
pMatchArm()  : string
pMaybeMultiline()  : string
pModifiers()  : string
Print modifiers, including trailing whitespace.
pName()  : string
pName_FullyQualified()  : string
pName_Relative()  : string
pNewOperand()  : string
pNullableType()  : string
pObjectProperty()  : string
pParam()  : string
pPostfixOp()  : string
Pretty-print a postfix operation while taking precedence into account.
pPrefixOp()  : string
Pretty-print a prefix operation while taking precedence into account.
pPropertyItem()  : string
preprocessNodes()  : void
Preprocesses the top-level nodes to initialize pretty printer state.
pScalar_Float()  : string
pScalar_Int()  : string
pScalar_InterpolatedString()  : string
pScalar_MagicConst_Class()  : string
pScalar_MagicConst_Dir()  : string
pScalar_MagicConst_File()  : string
pScalar_MagicConst_Function()  : string
pScalar_MagicConst_Line()  : string
pScalar_MagicConst_Method()  : string
pScalar_MagicConst_Namespace()  : string
pScalar_MagicConst_Trait()  : string
pScalar_String()  : string
pSingleQuotedString()  : string
pStatic()  : string
pStaticDereferenceLhs()  : string
pStaticVar()  : string
pStmt_Block()  : string
pStmt_Break()  : string
pStmt_Case()  : string
pStmt_Catch()  : string
pStmt_Class()  : string
pStmt_ClassConst()  : string
pStmt_ClassMethod()  : string
pStmt_Const()  : string
pStmt_Continue()  : string
pStmt_Declare()  : string
pStmt_Do()  : string
pStmt_Echo()  : string
pStmt_Else()  : string
pStmt_ElseIf()  : string
pStmt_Enum()  : string
pStmt_EnumCase()  : string
pStmt_Expression()  : string
pStmt_Finally()  : string
pStmt_For()  : string
pStmt_Foreach()  : string
pStmt_Function()  : string
pStmt_Global()  : string
pStmt_Goto()  : string
pStmt_GroupUse()  : string
pStmt_HaltCompiler()  : string
pStmt_If()  : string
pStmt_InlineHTML()  : string
pStmt_Interface()  : string
pStmt_Label()  : string
pStmt_Namespace()  : string
pStmt_Nop()  : string
pStmt_Property()  : string
pStmt_Return()  : string
pStmt_Static()  : string
pStmt_Switch()  : string
pStmt_Trait()  : string
pStmt_TraitUse()  : string
pStmt_TraitUseAdaptation_Alias()  : string
pStmt_TraitUseAdaptation_Precedence()  : string
pStmt_TryCatch()  : string
pStmt_Unset()  : string
pStmt_Use()  : string
pStmt_While()  : string
pStmts()  : string
Pretty prints an array of nodes (statements) and indents them optionally.
pUnionType()  : string
pUseItem()  : string
pUseType()  : string
pVariadicPlaceholder()  : string
pVarLikeIdentifier()  : string
resetState()  : void
Reset pretty printing state.
safeAppend()  : void
Appends to a string, ensuring whitespace between label characters.
setIndentLevel()  : void
Set indentation level
staticDereferenceLhsRequiresParens()  : bool
Determines whether the LHS of a static operation must be wrapped in parentheses.
indentString()  : string

Constants

Properties

$canUseSemicolonNamespaces

protected bool $canUseSemicolonNamespaces

Whether semicolon namespaces can be used (i.e. no global namespace is used)

$docStringEndToken

protected string|null $docStringEndToken

Token placed at end of doc string to ensure it is followed by a newline. Null if flexible doc strings are used.

$emptyListInsertionMap

protected array<string, array{: int|string|null, : string, : string}> $emptyListInsertionMap

$fixupMap

protected array<string, array<string, int>> $fixupMap

Map from token classes and subnode names to FIXUP_* constants. This is used during format-preserving prints to place additional parens/braces if necessary.

$insertionMap

protected array<string, array{: int|string|null, : bool, : string|null, : string|null}> $insertionMap

Map from "{$node->getType()}->{$subNode}" to [$find, $beforeToken, $extraLeft, $extraRight]. $find is an optional token after which the insertion occurs. $extraLeft/Right are optionally added before/after the main insertions.

$labelCharMap

protected array<string, bool> $labelCharMap

Map determining whether a certain character is a label character

$listInsertionMap

protected array<string, string> $listInsertionMap

Map From "{$class}->{$subNode}" to string that should be inserted between elements of this list subnode.

$modifierChangeMap

protected array<string, array{: string, : int}> $modifierChangeMap

Map from "{$class}->{$subNode}" to [$printFn, $token] where $printFn is the function to print the modifiers and $token is the token before which the modifiers should be reprinted.

$origTokens

protected TokenStream|null $origTokens

Original tokens for use in format-preserving pretty print

$precedenceMap

protected array<class-string, array{: int, : int, : int}> $precedenceMap = [ // [precedence, precedenceLHS, precedenceRHS] // Where the latter two are the precedences to use for the LHS and RHS of a binary operator, // where 1 is added to one of the sides depending on associativity. This information is not // used for unary operators and set to -1. \PhpParser\Node\Expr\Clone_::class => [-10, 0, 1], \PhpParser\Node\Expr\BinaryOp\Pow::class => [0, 0, 1], \PhpParser\Node\Expr\BitwiseNot::class => [10, -1, -1], \PhpParser\Node\Expr\UnaryPlus::class => [10, -1, -1], \PhpParser\Node\Expr\UnaryMinus::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\Int_::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\Double::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\String_::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\Array_::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\Object_::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\Bool_::class => [10, -1, -1], \PhpParser\Node\Expr\Cast\Unset_::class => [10, -1, -1], \PhpParser\Node\Expr\ErrorSuppress::class => [10, -1, -1], \PhpParser\Node\Expr\Instanceof_::class => [20, -1, -1], \PhpParser\Node\Expr\BooleanNot::class => [30, -1, -1], \PhpParser\Node\Expr\BinaryOp\Mul::class => [40, 41, 40], \PhpParser\Node\Expr\BinaryOp\Div::class => [40, 41, 40], \PhpParser\Node\Expr\BinaryOp\Mod::class => [40, 41, 40], \PhpParser\Node\Expr\BinaryOp\Plus::class => [50, 51, 50], \PhpParser\Node\Expr\BinaryOp\Minus::class => [50, 51, 50], \PhpParser\Node\Expr\BinaryOp\Concat::class => [50, 51, 50], \PhpParser\Node\Expr\BinaryOp\ShiftLeft::class => [60, 61, 60], \PhpParser\Node\Expr\BinaryOp\ShiftRight::class => [60, 61, 60], \PhpParser\Node\Expr\BinaryOp\Smaller::class => [70, 70, 70], \PhpParser\Node\Expr\BinaryOp\SmallerOrEqual::class => [70, 70, 70], \PhpParser\Node\Expr\BinaryOp\Greater::class => [70, 70, 70], \PhpParser\Node\Expr\BinaryOp\GreaterOrEqual::class => [70, 70, 70], \PhpParser\Node\Expr\BinaryOp\Equal::class => [80, 80, 80], \PhpParser\Node\Expr\BinaryOp\NotEqual::class => [80, 80, 80], \PhpParser\Node\Expr\BinaryOp\Identical::class => [80, 80, 80], \PhpParser\Node\Expr\BinaryOp\NotIdentical::class => [80, 80, 80], \PhpParser\Node\Expr\BinaryOp\Spaceship::class => [80, 80, 80], \PhpParser\Node\Expr\BinaryOp\BitwiseAnd::class => [90, 91, 90], \PhpParser\Node\Expr\BinaryOp\BitwiseXor::class => [100, 101, 100], \PhpParser\Node\Expr\BinaryOp\BitwiseOr::class => [110, 111, 110], \PhpParser\Node\Expr\BinaryOp\BooleanAnd::class => [120, 121, 120], \PhpParser\Node\Expr\BinaryOp\BooleanOr::class => [130, 131, 130], \PhpParser\Node\Expr\BinaryOp\Coalesce::class => [140, 140, 141], \PhpParser\Node\Expr\Ternary::class => [150, -1, -1], \PhpParser\Node\Expr\Assign::class => [160, -1, -1], \PhpParser\Node\Expr\AssignRef::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Plus::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Minus::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Mul::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Div::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Concat::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Mod::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\BitwiseAnd::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\BitwiseOr::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\BitwiseXor::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\ShiftLeft::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\ShiftRight::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Pow::class => [160, -1, -1], \PhpParser\Node\Expr\AssignOp\Coalesce::class => [160, -1, -1], \PhpParser\Node\Expr\YieldFrom::class => [170, -1, -1], \PhpParser\Node\Expr\Yield_::class => [175, -1, -1], \PhpParser\Node\Expr\Print_::class => [180, -1, -1], \PhpParser\Node\Expr\BinaryOp\LogicalAnd::class => [190, 191, 190], \PhpParser\Node\Expr\BinaryOp\LogicalXor::class => [200, 201, 200], \PhpParser\Node\Expr\BinaryOp\LogicalOr::class => [210, 211, 210], \PhpParser\Node\Expr\Include_::class => [220, -1, -1], \PhpParser\Node\Expr\ArrowFunction::class => [230, -1, -1], \PhpParser\Node\Expr\Throw_::class => [240, -1, -1], ]

$removalMap

protected array<string, array{left?: int|string, right?: int|string}> $removalMap

Map from "{$node->getType()}->{$subNode}" to ['left' => $l, 'right' => $r], where $l and $r specify the token type that needs to be stripped when removing this node.

$shortArraySyntax

protected bool $shortArraySyntax

Whether to use short array syntax if the node specifies no preference

Methods

__construct()

Creates a pretty printer instance using the given options.

public __construct([PhpVersion, newline?: string, shortArraySyntax?: bool} $options = [] ]) : mixed

Supported options:

  • PhpVersion $phpVersion: The PHP version to target (default to PHP 7.4). This option controls compatibility of the generated code with older PHP versions in cases where a simple stylistic choice exists (e.g. array() vs []). It is safe to pretty-print an AST for a newer PHP version while specifying an older target (but the result will of course not be compatible with the older version in that case).
  • string $newline: The newline style to use. Should be "\n" (default) or "\r\n".
  • bool $shortArraySyntax: Whether to use [] instead of array() as the default array syntax, if the node does not specify a format. Defaults to whether the phpVersion support short array syntax.
Parameters
$options : PhpVersion, newline?: string, shortArraySyntax?: bool} = []

Dictionary of formatting options

prettyPrint()

Pretty prints an array of statements.

public prettyPrint(array<string|int, Node$stmts) : string
Parameters
$stmts : array<string|int, Node>

Array of statements

Return values
string

Pretty printed statements

prettyPrintExpr()

Pretty prints an expression.

public prettyPrintExpr(Expr $node) : string
Parameters
$node : Expr

Expression node

Return values
string

Pretty printed node

prettyPrintFile()

Pretty prints a file of statements (includes the opening <?php tag if it is required).

public prettyPrintFile(array<string|int, Node$stmts) : string
Parameters
$stmts : array<string|int, Node>

Array of statements

Return values
string

Pretty printed statements

printFormatPreserving()

Perform a format-preserving pretty print of an AST.

public printFormatPreserving(array<string|int, Node$stmts, array<string|int, Node$origStmts, array<string|int, Token$origTokens) : string

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 : array<string|int, Node>

Modified AST with links to original AST

$origStmts : array<string|int, Node>

Original AST with token offset information

$origTokens : array<string|int, Token>

Tokens of the original code

Return values
string

callLhsRequiresParens()

Determines whether the LHS of a call must be wrapped in parenthesis.

protected callLhsRequiresParens(Node $node) : bool
Parameters
$node : Node

LHS of a call

Return values
bool

Whether parentheses are required

containsEndLabel()

protected containsEndLabel(string $string, string $label[, bool $atStart = true ]) : bool
Parameters
$string : string
$label : string
$atStart : bool = true
Return values
bool

dereferenceLhsRequiresParens()

Determines whether the LHS of an array/object operation must be wrapped in parentheses.

protected dereferenceLhsRequiresParens(Node $node) : bool
Parameters
$node : Node

LHS of dereferencing operation

Return values
bool

Whether parentheses are required

escapeString()

protected escapeString(string $string, string|null $quote) : string
Parameters
$string : string
$quote : string|null
Return values
string

handleMagicTokens()

Handles (and removes) doc-string-end tokens.

protected handleMagicTokens(string $str) : string
Parameters
$str : string
Return values
string

hasNodeWithComments()

protected hasNodeWithComments(array<string|int, Node$nodes) : bool
Parameters
$nodes : array<string|int, Node>
Return values
bool

initializeFixupMap()

Lazily initializes fixup map.

protected initializeFixupMap() : void

The fixup map is used to determine whether a certain subnode of a certain node may require some kind of "fixup" operation, e.g. the addition of parenthesis or braces.

initializeLabelCharMap()

Lazily initializes label char map.

protected initializeLabelCharMap() : void

The label char map determines whether a certain character may occur in a label.

initializeNodeListDiffer()

Lazily initializes node list differ.

protected initializeNodeListDiffer() : void

The node list differ is used to determine differences between two array subnodes.

initializeRemovalMap()

Lazily initializes the removal map.

protected initializeRemovalMap() : void

The removal map is used to determine which additional tokens should be removed when a certain node is replaced by null.

isMultiline()

Determine whether a list of nodes uses multiline formatting.

protected isMultiline(array<string|int, Node|null> $nodes) : bool
Parameters
$nodes : array<string|int, Node|null>

Node list

Return values
bool

Whether multiline formatting is used

newOperandRequiresParens()

Determines whether an expression used in "new" or "instanceof" requires parentheses.

protected newOperandRequiresParens(Node $node) : bool
Parameters
$node : Node

New or instanceof operand

Return values
bool

Whether parentheses are required

p()

Pretty prints a node.

protected p(Node $node[, int $precedence = self::MAX_PRECEDENCE ][, int $lhsPrecedence = self::MAX_PRECEDENCE ][, bool $parentFormatPreserved = false ]) : string

This method also handles formatting preservation for nodes.

Parameters
$node : Node

Node to be pretty printed

$precedence : int = self::MAX_PRECEDENCE

Precedence of parent operator

$lhsPrecedence : int = self::MAX_PRECEDENCE

Precedence for unary operator on LHS of binary operator

$parentFormatPreserved : bool = false

Whether parent node has preserved formatting

Return values
string

Pretty printed node

pArg()

protected pArg(Arg $node) : string
Parameters
$node : Arg
Return values
string

pArray()

Perform a format-preserving pretty print of an array.

protected pArray(array<string|int, Node$nodes, array<string|int, Node$origNodes, int &$pos, int $indentAdjustment, string $parentNodeClass, string $subNodeName, null|int $fixup) : null|string
Parameters
$nodes : array<string|int, Node>

New nodes

$origNodes : array<string|int, Node>

Original nodes

$pos : int

Current token position (updated by reference)

$indentAdjustment : int

Adjustment for indentation

$parentNodeClass : string

Class of the containing node.

$subNodeName : string

Name of array subnode.

$fixup : null|int

Fixup information for array item nodes

Return values
null|string

Result of pretty print or null if cannot preserve formatting

pAttrGroups()

protected pAttrGroups(array<string|int, AttributeGroup$nodes[, bool $inline = false ]) : string
Parameters
$nodes : array<string|int, AttributeGroup>
$inline : bool = false
Return values
string

pCallLhs()

protected pCallLhs(Node $node) : string
Parameters
$node : Node
Return values
string

pClassCommon()

protected pClassCommon(Class_ $node, string $afterClassToken) : string
Parameters
$node : Class_
$afterClassToken : string
Return values
string

pCommaSeparated()

Pretty prints an array of nodes and implodes the printed values with commas.

protected pCommaSeparated(array<string|int, Node$nodes) : string
Parameters
$nodes : array<string|int, Node>

Array of Nodes to be printed

Return values
string

Comma separated pretty printed nodes

pCommaSeparatedMultiline()

Pretty prints a comma-separated list of nodes in multiline style, including comments.

protected pCommaSeparatedMultiline(array<string|int, Node$nodes, bool $trailingComma) : string

The result includes a leading newline and one level of indentation (same as pStmts).

Parameters
$nodes : array<string|int, Node>

Array of Nodes to be printed

$trailingComma : bool

Whether to use a trailing comma

Return values
string

Comma separated pretty printed nodes in multiline style

pComments()

Prints reformatted text of the passed comments.

protected pComments(array<string|int, Comment$comments) : string
Parameters
$comments : array<string|int, Comment>

List of comments

Return values
string

Reformatted text of comments

pDereferenceLhs()

protected pDereferenceLhs(Node $node) : string
Parameters
$node : Node
Return values
string

pExpr_Array()

protected pExpr_Array(Array_ $node) : string
Parameters
$node : Array_
Return values
string

pExpr_ArrowFunction()

protected pExpr_ArrowFunction(ArrowFunction $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : ArrowFunction
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Assign()

protected pExpr_Assign(Assign $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Assign
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_BitwiseAnd()

protected pExpr_AssignOp_BitwiseAnd(BitwiseAnd $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseAnd
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_BitwiseOr()

protected pExpr_AssignOp_BitwiseOr(BitwiseOr $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseOr
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_BitwiseXor()

protected pExpr_AssignOp_BitwiseXor(BitwiseXor $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseXor
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Coalesce()

protected pExpr_AssignOp_Coalesce(Coalesce $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Coalesce
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Concat()

protected pExpr_AssignOp_Concat(Concat $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Concat
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Div()

protected pExpr_AssignOp_Div(Div $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Div
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Minus()

protected pExpr_AssignOp_Minus(Minus $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Minus
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Mod()

protected pExpr_AssignOp_Mod(Mod $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Mod
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Mul()

protected pExpr_AssignOp_Mul(Mul $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Mul
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Plus()

protected pExpr_AssignOp_Plus(Plus $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Plus
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_Pow()

protected pExpr_AssignOp_Pow(Pow $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Pow
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_ShiftLeft()

protected pExpr_AssignOp_ShiftLeft(ShiftLeft $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : ShiftLeft
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignOp_ShiftRight()

protected pExpr_AssignOp_ShiftRight(ShiftRight $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : ShiftRight
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_AssignRef()

protected pExpr_AssignRef(AssignRef $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : AssignRef
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_BitwiseAnd()

protected pExpr_BinaryOp_BitwiseAnd(BitwiseAnd $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseAnd
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_BitwiseOr()

protected pExpr_BinaryOp_BitwiseOr(BitwiseOr $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseOr
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_BitwiseXor()

protected pExpr_BinaryOp_BitwiseXor(BitwiseXor $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseXor
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_BooleanAnd()

protected pExpr_BinaryOp_BooleanAnd(BooleanAnd $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BooleanAnd
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_BooleanOr()

protected pExpr_BinaryOp_BooleanOr(BooleanOr $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BooleanOr
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Coalesce()

protected pExpr_BinaryOp_Coalesce(Coalesce $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Coalesce
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Concat()

protected pExpr_BinaryOp_Concat(Concat $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Concat
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Div()

protected pExpr_BinaryOp_Div(Div $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Div
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Equal()

protected pExpr_BinaryOp_Equal(Equal $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Equal
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Greater()

protected pExpr_BinaryOp_Greater(Greater $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Greater
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_GreaterOrEqual()

protected pExpr_BinaryOp_GreaterOrEqual(GreaterOrEqual $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : GreaterOrEqual
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Identical()

protected pExpr_BinaryOp_Identical(Identical $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Identical
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_LogicalAnd()

protected pExpr_BinaryOp_LogicalAnd(LogicalAnd $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : LogicalAnd
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_LogicalOr()

protected pExpr_BinaryOp_LogicalOr(LogicalOr $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : LogicalOr
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_LogicalXor()

protected pExpr_BinaryOp_LogicalXor(LogicalXor $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : LogicalXor
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Minus()

protected pExpr_BinaryOp_Minus(Minus $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Minus
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Mod()

protected pExpr_BinaryOp_Mod(Mod $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Mod
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Mul()

protected pExpr_BinaryOp_Mul(Mul $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Mul
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_NotEqual()

protected pExpr_BinaryOp_NotEqual(NotEqual $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : NotEqual
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_NotIdentical()

protected pExpr_BinaryOp_NotIdentical(NotIdentical $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : NotIdentical
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Plus()

protected pExpr_BinaryOp_Plus(Plus $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Plus
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Pow()

protected pExpr_BinaryOp_Pow(Pow $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Pow
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_ShiftLeft()

protected pExpr_BinaryOp_ShiftLeft(ShiftLeft $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : ShiftLeft
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_ShiftRight()

protected pExpr_BinaryOp_ShiftRight(ShiftRight $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : ShiftRight
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Smaller()

protected pExpr_BinaryOp_Smaller(Smaller $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Smaller
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_SmallerOrEqual()

protected pExpr_BinaryOp_SmallerOrEqual(SmallerOrEqual $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : SmallerOrEqual
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BinaryOp_Spaceship()

protected pExpr_BinaryOp_Spaceship(Spaceship $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Spaceship
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BitwiseNot()

protected pExpr_BitwiseNot(BitwiseNot $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BitwiseNot
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_BooleanNot()

protected pExpr_BooleanNot(BooleanNot $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : BooleanNot
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_Array()

protected pExpr_Cast_Array(Array_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Array_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_Bool()

protected pExpr_Cast_Bool(Bool_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Bool_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_Double()

protected pExpr_Cast_Double(Double $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Double
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_Int()

protected pExpr_Cast_Int(Int_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Int_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_Object()

protected pExpr_Cast_Object(Object_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Object_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_String()

protected pExpr_Cast_String(String_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : String_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Cast_Unset()

protected pExpr_Cast_Unset(Unset_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Unset_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Clone()

protected pExpr_Clone(Clone_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Clone_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Closure()

protected pExpr_Closure(Closure $node) : string
Parameters
$node : Closure
Return values
string

pExpr_Empty()

protected pExpr_Empty(Empty_ $node) : string
Parameters
$node : Empty_
Return values
string

pExpr_Error()

protected pExpr_Error(Error $node) : string
Parameters
$node : Error
Return values
string

pExpr_ErrorSuppress()

protected pExpr_ErrorSuppress(ErrorSuppress $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : ErrorSuppress
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Eval()

protected pExpr_Eval(Eval_ $node) : string
Parameters
$node : Eval_
Return values
string

pExpr_Exit()

protected pExpr_Exit(Exit_ $node) : string
Parameters
$node : Exit_
Return values
string

pExpr_Include()

protected pExpr_Include(Include_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Include_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Instanceof()

protected pExpr_Instanceof(Instanceof_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Instanceof_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Isset()

protected pExpr_Isset(Isset_ $node) : string
Parameters
$node : Isset_
Return values
string

pExpr_List()

protected pExpr_List(List_ $node) : string
Parameters
$node : List_
Return values
string

pExpr_Match()

protected pExpr_Match(Match_ $node) : string
Parameters
$node : Match_
Return values
string

pExpr_New()

protected pExpr_New(New_ $node) : string
Parameters
$node : New_
Return values
string

pExpr_PostDec()

protected pExpr_PostDec(PostDec $node) : string
Parameters
$node : PostDec
Return values
string

pExpr_PostInc()

protected pExpr_PostInc(PostInc $node) : string
Parameters
$node : PostInc
Return values
string

pExpr_PreDec()

protected pExpr_PreDec(PreDec $node) : string
Parameters
$node : PreDec
Return values
string

pExpr_PreInc()

protected pExpr_PreInc(PreInc $node) : string
Parameters
$node : PreInc
Return values
string

pExpr_Print()

protected pExpr_Print(Print_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Print_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Ternary()

protected pExpr_Ternary(Ternary $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Ternary
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Throw()

protected pExpr_Throw(Throw_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Throw_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_UnaryMinus()

protected pExpr_UnaryMinus(UnaryMinus $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : UnaryMinus
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_UnaryPlus()

protected pExpr_UnaryPlus(UnaryPlus $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : UnaryPlus
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_Yield()

protected pExpr_Yield(Yield_ $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Yield_
$precedence : int
$lhsPrecedence : int
Return values
string

pExpr_YieldFrom()

protected pExpr_YieldFrom(YieldFrom $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : YieldFrom
$precedence : int
$lhsPrecedence : int
Return values
string

pFallback()

protected pFallback(Node $node, int $precedence, int $lhsPrecedence) : string
Parameters
$node : Node
$precedence : int
$lhsPrecedence : int
Return values
string

pFixup()

Print node with fixups.

protected pFixup(int $fixup, Node $subNode, string|null $parentClass, int $subStartPos, int $subEndPos) : string

Fixups here refer to the addition of extra parentheses, braces or other characters, that are required to preserve program semantics in a certain context (e.g. to maintain precedence or because only certain expressions are allowed in certain places).

Parameters
$fixup : int

Fixup type

$subNode : Node

Subnode to print

$parentClass : string|null

Class of parent node

$subStartPos : int

Original start pos of subnode

$subEndPos : int

Original end pos of subnode

Return values
string

Result of fixed-up print of subnode

pImplode()

Pretty prints an array of nodes and implodes the printed values.

protected pImplode(array<string|int, Node$nodes[, string $glue = '' ]) : string
Parameters
$nodes : array<string|int, Node>

Array of Nodes to be printed

$glue : string = ''

Character to implode with

Return values
string

Imploded pretty printed nodes> $pre

pInfixOp()

Pretty-print an infix operation while taking precedence into account.

protected pInfixOp(string $class, Node $leftNode, string $operatorString, Node $rightNode, int $precedence, int $lhsPrecedence) : string
Parameters
$class : string

Node class of operator

$leftNode : Node

Left-hand side node

$operatorString : string

String representation of the operator

$rightNode : Node

Right-hand side node

$precedence : int

Precedence of parent operator

$lhsPrecedence : int

Precedence for unary operator on LHS of binary operator

Return values
string

Pretty printed infix operation

pKey()

protected pKey(Node|null $node) : string
Parameters
$node : Node|null
Return values
string

pMaybeMultiline()

protected pMaybeMultiline(array<string|int, Node$nodes[, bool $trailingComma = false ]) : string
Parameters
$nodes : array<string|int, Node>
$trailingComma : bool = false
Return values
string

pModifiers()

Print modifiers, including trailing whitespace.

protected pModifiers(int $modifiers) : string
Parameters
$modifiers : int

Modifier mask to print

Return values
string

Printed modifiers

pName()

protected pName(Name $node) : string
Parameters
$node : Name
Return values
string

pNewOperand()

protected pNewOperand(Node $node) : string
Parameters
$node : Node
Return values
string

pObjectProperty()

protected pObjectProperty(Node $node) : string
Parameters
$node : Node
Return values
string

pParam()

protected pParam(Param $node) : string
Parameters
$node : Param
Return values
string

pPostfixOp()

Pretty-print a postfix operation while taking precedence into account.

protected pPostfixOp(string $class, Node $node, string $operatorString, int $precedence, int $lhsPrecedence) : string
Parameters
$class : string

Node class of operator

$node : Node

Node

$operatorString : string

String representation of the operator

$precedence : int

Precedence of parent operator

$lhsPrecedence : int

Precedence for unary operator on LHS of binary operator

Return values
string

Pretty printed postfix operation

pPrefixOp()

Pretty-print a prefix operation while taking precedence into account.

protected pPrefixOp(string $class, string $operatorString, Node $node, int $precedence, int $lhsPrecedence) : string
Parameters
$class : string

Node class of operator

$operatorString : string

String representation of the operator

$node : Node

Node

$precedence : int

Precedence of parent operator

$lhsPrecedence : int

Precedence for unary operator on LHS of binary operator

Return values
string

Pretty printed prefix operation

preprocessNodes()

Preprocesses the top-level nodes to initialize pretty printer state.

protected preprocessNodes(array<string|int, Node$nodes) : void
Parameters
$nodes : array<string|int, Node>

Array of nodes

pScalar_Float()

protected pScalar_Float(Float_ $node) : string
Parameters
$node : Float_
Return values
string

pScalar_Int()

protected pScalar_Int(Int_ $node) : string
Parameters
$node : Int_
Return values
string

pScalar_MagicConst_Class()

protected pScalar_MagicConst_Class(Class_ $node) : string
Parameters
$node : Class_
Return values
string

pScalar_MagicConst_Dir()

protected pScalar_MagicConst_Dir(Dir $node) : string
Parameters
$node : Dir
Return values
string

pScalar_MagicConst_File()

protected pScalar_MagicConst_File(File $node) : string
Parameters
$node : File
Return values
string

pScalar_MagicConst_Function()

protected pScalar_MagicConst_Function(Function_ $node) : string
Parameters
$node : Function_
Return values
string

pScalar_MagicConst_Line()

protected pScalar_MagicConst_Line(Line $node) : string
Parameters
$node : Line
Return values
string

pScalar_MagicConst_Method()

protected pScalar_MagicConst_Method(Method $node) : string
Parameters
$node : Method
Return values
string

pScalar_MagicConst_Namespace()

protected pScalar_MagicConst_Namespace(Namespace_ $node) : string
Parameters
$node : Namespace_
Return values
string

pScalar_MagicConst_Trait()

protected pScalar_MagicConst_Trait(Trait_ $node) : string
Parameters
$node : Trait_
Return values
string

pScalar_String()

protected pScalar_String(String_ $node) : string
Parameters
$node : String_
Return values
string

pSingleQuotedString()

protected pSingleQuotedString(string $string) : string
Parameters
$string : string
Return values
string

pStatic()

protected pStatic(bool $static) : string
Parameters
$static : bool
Return values
string

pStaticDereferenceLhs()

protected pStaticDereferenceLhs(Node $node) : string
Parameters
$node : Node
Return values
string

pStmt_Block()

protected pStmt_Block(Block $node) : string
Parameters
$node : Block
Return values
string

pStmt_Break()

protected pStmt_Break(Break_ $node) : string
Parameters
$node : Break_
Return values
string

pStmt_Case()

protected pStmt_Case(Case_ $node) : string
Parameters
$node : Case_
Return values
string

pStmt_Catch()

protected pStmt_Catch(Catch_ $node) : string
Parameters
$node : Catch_
Return values
string

pStmt_Class()

protected pStmt_Class(Class_ $node) : string
Parameters
$node : Class_
Return values
string

pStmt_Const()

protected pStmt_Const(Const_ $node) : string
Parameters
$node : Const_
Return values
string

pStmt_Do()

protected pStmt_Do(Do_ $node) : string
Parameters
$node : Do_
Return values
string

pStmt_Echo()

protected pStmt_Echo(Echo_ $node) : string
Parameters
$node : Echo_
Return values
string

pStmt_Else()

protected pStmt_Else(Else_ $node) : string
Parameters
$node : Else_
Return values
string

pStmt_ElseIf()

protected pStmt_ElseIf(ElseIf_ $node) : string
Parameters
$node : ElseIf_
Return values
string

pStmt_Enum()

protected pStmt_Enum(Enum_ $node) : string
Parameters
$node : Enum_
Return values
string

pStmt_For()

protected pStmt_For(For_ $node) : string
Parameters
$node : For_
Return values
string

pStmt_Global()

protected pStmt_Global(Global_ $node) : string
Parameters
$node : Global_
Return values
string

pStmt_Goto()

protected pStmt_Goto(Goto_ $node) : string
Parameters
$node : Goto_
Return values
string

pStmt_If()

protected pStmt_If(If_ $node) : string
Parameters
$node : If_
Return values
string

pStmt_Label()

protected pStmt_Label(Label $node) : string
Parameters
$node : Label
Return values
string

pStmt_Nop()

protected pStmt_Nop(Nop $node) : string
Parameters
$node : Nop
Return values
string

pStmt_Return()

protected pStmt_Return(Return_ $node) : string
Parameters
$node : Return_
Return values
string

pStmt_Static()

protected pStmt_Static(Static_ $node) : string
Parameters
$node : Static_
Return values
string

pStmt_Switch()

protected pStmt_Switch(Switch_ $node) : string
Parameters
$node : Switch_
Return values
string

pStmt_Trait()

protected pStmt_Trait(Trait_ $node) : string
Parameters
$node : Trait_
Return values
string

pStmt_TraitUseAdaptation_Alias()

protected pStmt_TraitUseAdaptation_Alias(Alias $node) : string
Parameters
$node : Alias
Return values
string

pStmt_TraitUseAdaptation_Precedence()

protected pStmt_TraitUseAdaptation_Precedence(Precedence $node) : string
Parameters
$node : Precedence
Return values
string

pStmt_Unset()

protected pStmt_Unset(Unset_ $node) : string
Parameters
$node : Unset_
Return values
string

pStmt_Use()

protected pStmt_Use(Use_ $node) : string
Parameters
$node : Use_
Return values
string

pStmt_While()

protected pStmt_While(While_ $node) : string
Parameters
$node : While_
Return values
string

pStmts()

Pretty prints an array of nodes (statements) and indents them optionally.

protected pStmts(array<string|int, Node$nodes[, bool $indent = true ]) : string
Parameters
$nodes : array<string|int, Node>

Array of nodes

$indent : bool = true

Whether to indent the printed nodes

Return values
string

Pretty printed statements

pUseType()

protected pUseType(int $type) : string
Parameters
$type : int
Return values
string

safeAppend()

Appends to a string, ensuring whitespace between label characters.

protected safeAppend(string &$str, string $append) : void

Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x". Without safeAppend the result would be "echox", which does not preserve semantics.

Parameters
$str : string
$append : string

setIndentLevel()

Set indentation level

protected setIndentLevel(int $level) : void
Parameters
$level : int

Level in number of spaces

staticDereferenceLhsRequiresParens()

Determines whether the LHS of a static operation must be wrapped in parentheses.

protected staticDereferenceLhsRequiresParens(Node $node) : bool
Parameters
$node : Node

LHS of dereferencing operation

Return values
bool

Whether parentheses are required

indentString()

private indentString(string $str) : string
Parameters
$str : string
Return values
string

        
On this page

Search results