\PhpParser\PrettyPrinterStandard

Summary

Methods
Properties
Constants
__construct()
prettyPrint()
prettyPrintExpr()
prettyPrintFile()
No public properties found
No constants found
preprocessNodes()
handleMagicTokens()
pStmts()
p()
pInfixOp()
pPrefixOp()
pPostfixOp()
pPrec()
pImplode()
pCommaSeparated()
pCommaSeparatedMultiline()
pNoIndent()
pComments()
pParam()
pArg()
pConst()
pNullableType()
pName()
pName_FullyQualified()
pName_Relative()
pScalar_MagicConst_Class()
pScalar_MagicConst_Dir()
pScalar_MagicConst_File()
pScalar_MagicConst_Function()
pScalar_MagicConst_Line()
pScalar_MagicConst_Method()
pScalar_MagicConst_Namespace()
pScalar_MagicConst_Trait()
pScalar_String()
pScalar_Encapsed()
pScalar_LNumber()
pScalar_DNumber()
pExpr_Assign()
pExpr_AssignRef()
pExpr_AssignOp_Plus()
pExpr_AssignOp_Minus()
pExpr_AssignOp_Mul()
pExpr_AssignOp_Div()
pExpr_AssignOp_Concat()
pExpr_AssignOp_Mod()
pExpr_AssignOp_BitwiseAnd()
pExpr_AssignOp_BitwiseOr()
pExpr_AssignOp_BitwiseXor()
pExpr_AssignOp_ShiftLeft()
pExpr_AssignOp_ShiftRight()
pExpr_AssignOp_Pow()
pExpr_BinaryOp_Plus()
pExpr_BinaryOp_Minus()
pExpr_BinaryOp_Mul()
pExpr_BinaryOp_Div()
pExpr_BinaryOp_Concat()
pExpr_BinaryOp_Mod()
pExpr_BinaryOp_BooleanAnd()
pExpr_BinaryOp_BooleanOr()
pExpr_BinaryOp_BitwiseAnd()
pExpr_BinaryOp_BitwiseOr()
pExpr_BinaryOp_BitwiseXor()
pExpr_BinaryOp_ShiftLeft()
pExpr_BinaryOp_ShiftRight()
pExpr_BinaryOp_Pow()
pExpr_BinaryOp_LogicalAnd()
pExpr_BinaryOp_LogicalOr()
pExpr_BinaryOp_LogicalXor()
pExpr_BinaryOp_Equal()
pExpr_BinaryOp_NotEqual()
pExpr_BinaryOp_Identical()
pExpr_BinaryOp_NotIdentical()
pExpr_BinaryOp_Spaceship()
pExpr_BinaryOp_Greater()
pExpr_BinaryOp_GreaterOrEqual()
pExpr_BinaryOp_Smaller()
pExpr_BinaryOp_SmallerOrEqual()
pExpr_BinaryOp_Coalesce()
pExpr_Instanceof()
pExpr_BooleanNot()
pExpr_BitwiseNot()
pExpr_UnaryMinus()
pExpr_UnaryPlus()
pExpr_PreInc()
pExpr_PreDec()
pExpr_PostInc()
pExpr_PostDec()
pExpr_ErrorSuppress()
pExpr_YieldFrom()
pExpr_Print()
pExpr_Cast_Int()
pExpr_Cast_Double()
pExpr_Cast_String()
pExpr_Cast_Array()
pExpr_Cast_Object()
pExpr_Cast_Bool()
pExpr_Cast_Unset()
pExpr_FuncCall()
pExpr_MethodCall()
pExpr_StaticCall()
pExpr_Empty()
pExpr_Isset()
pExpr_Eval()
pExpr_Include()
pExpr_List()
pExpr_Error()
pExpr_Variable()
pExpr_Array()
pExpr_ArrayItem()
pExpr_ArrayDimFetch()
pExpr_ConstFetch()
pExpr_ClassConstFetch()
pExpr_PropertyFetch()
pExpr_StaticPropertyFetch()
pExpr_ShellExec()
pExpr_Closure()
pExpr_ClosureUse()
pExpr_New()
pExpr_Clone()
pExpr_Ternary()
pExpr_Exit()
pExpr_Yield()
pStmt_Namespace()
pStmt_Use()
pStmt_GroupUse()
pStmt_UseUse()
pUseType()
pStmt_Interface()
pStmt_Class()
pStmt_Trait()
pStmt_TraitUse()
pStmt_TraitUseAdaptation_Precedence()
pStmt_TraitUseAdaptation_Alias()
pStmt_Property()
pStmt_PropertyProperty()
pStmt_ClassMethod()
pStmt_ClassConst()
pStmt_Function()
pStmt_Const()
pStmt_Declare()
pStmt_DeclareDeclare()
pStmt_If()
pStmt_ElseIf()
pStmt_Else()
pStmt_For()
pStmt_Foreach()
pStmt_While()
pStmt_Do()
pStmt_Switch()
pStmt_Case()
pStmt_TryCatch()
pStmt_Catch()
pStmt_Finally()
pStmt_Break()
pStmt_Continue()
pStmt_Return()
pStmt_Throw()
pStmt_Label()
pStmt_Goto()
pStmt_Echo()
pStmt_Static()
pStmt_Global()
pStmt_StaticVar()
pStmt_Unset()
pStmt_InlineHTML()
pStmt_HaltCompiler()
pStmt_Nop()
pType()
pClassCommon()
pObjectProperty()
pModifiers()
pEncapsList()
escapeString()
containsEndLabel()
encapsedContainsEndLabel()
pDereferenceLhs()
pCallLhs()
$precedenceMap
$noIndentToken
$docStringEndToken
$canUseSemicolonNamespaces
$options
N/A
hasNodeWithComments()
pMaybeMultiline()
No private properties found
N/A

Properties

$precedenceMap

$precedenceMap : 

Type

$noIndentToken

$noIndentToken : 

Type

$docStringEndToken

$docStringEndToken : 

Type

$canUseSemicolonNamespaces

$canUseSemicolonNamespaces : 

Type

$options

$options : 

Type

Methods

__construct()

__construct(array  $options = array()) 

Creates a pretty printer instance using the given options.

Supported options:

  • bool $shortArraySyntax = false: Whether to use [] instead of array() as the default array syntax, if the node does not specify a format.

Parameters

array $options

Dictionary of formatting options

prettyPrint()

prettyPrint(array<mixed,\PhpParser\Node>  $stmts) : string

Pretty prints an array of statements.

Parameters

array<mixed,\PhpParser\Node> $stmts

Array of statements

Returns

string —

Pretty printed statements

prettyPrintExpr()

prettyPrintExpr(\PhpParser\Node\Expr  $node) : string

Pretty prints an expression.

Parameters

\PhpParser\Node\Expr $node

Expression node

Returns

string —

Pretty printed node

prettyPrintFile()

prettyPrintFile(array<mixed,\PhpParser\Node>  $stmts) : string

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

Parameters

array<mixed,\PhpParser\Node> $stmts

Array of statements

Returns

string —

Pretty printed statements

preprocessNodes()

preprocessNodes(array<mixed,\PhpParser\Node>  $nodes) 

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

Parameters

array<mixed,\PhpParser\Node> $nodes

Array of nodes

handleMagicTokens()

handleMagicTokens(  $str) 

Parameters

$str

pStmts()

pStmts(array<mixed,\PhpParser\Node>  $nodes, boolean  $indent = true) : string

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

Parameters

array<mixed,\PhpParser\Node> $nodes

Array of nodes

boolean $indent

Whether to indent the printed nodes

Returns

string —

Pretty printed statements

p()

p(\PhpParser\Node  $node) : string

Pretty prints a node.

Parameters

\PhpParser\Node $node

Node to be pretty printed

Returns

string —

Pretty printed node

pInfixOp()

pInfixOp(  $type, \PhpParser\Node  $leftNode,   $operatorString, \PhpParser\Node  $rightNode) 

Parameters

$type
\PhpParser\Node $leftNode
$operatorString
\PhpParser\Node $rightNode

pPrefixOp()

pPrefixOp(  $type,   $operatorString, \PhpParser\Node  $node) 

Parameters

$type
$operatorString
\PhpParser\Node $node

pPostfixOp()

pPostfixOp(  $type, \PhpParser\Node  $node,   $operatorString) 

Parameters

$type
\PhpParser\Node $node
$operatorString

pPrec()

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.

Parameters

\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)

Returns

string —

The pretty printed node

pImplode()

pImplode(array<mixed,\PhpParser\Node>  $nodes, string  $glue = '') : string

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

Parameters

array<mixed,\PhpParser\Node> $nodes

Array of Nodes to be printed

string $glue

Character to implode with

Returns

string —

Imploded pretty printed nodes

pCommaSeparated()

pCommaSeparated(array<mixed,\PhpParser\Node>  $nodes) : string

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

Parameters

array<mixed,\PhpParser\Node> $nodes

Array of Nodes to be printed

Returns

string —

Comma separated pretty printed nodes

pCommaSeparatedMultiline()

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).

Parameters

array<mixed,\PhpParser\Node> $nodes

Array of Nodes to be printed

boolean $trailingComma

Whether to use a trailing comma

Returns

string —

Comma separated pretty printed nodes in multiline style

pNoIndent()

pNoIndent(string  $string) : string

Signals the pretty printer that a string shall not be indented.

Parameters

string $string

Not to be indented string

Returns

string —

String marked with $this->noIndentToken's.

pComments()

pComments(array<mixed,\PhpParser\Comment>  $comments) : string

Prints reformatted text of the passed comments.

Parameters

array<mixed,\PhpParser\Comment> $comments

List of comments

Returns

string —

Reformatted text of comments

pUseType()

pUseType(  $type) 

Parameters

$type

pType()

pType(  $node) 

Parameters

$node

pClassCommon()

pClassCommon(\PhpParser\Node\Stmt\Class_  $node,   $afterClassToken) 

Parameters

\PhpParser\Node\Stmt\Class_ $node
$afterClassToken

pObjectProperty()

pObjectProperty(  $node) 

Parameters

$node

pModifiers()

pModifiers(  $modifiers) 

Parameters

$modifiers

pEncapsList()

pEncapsList(array  $encapsList,   $quote) 

Parameters

array $encapsList
$quote

escapeString()

escapeString(  $string,   $quote) 

Parameters

$string
$quote

containsEndLabel()

containsEndLabel(  $string,   $label,   $atStart = true,   $atEnd = true) 

Parameters

$string
$label
$atStart
$atEnd

encapsedContainsEndLabel()

encapsedContainsEndLabel(array  $parts,   $label) 

Parameters

array $parts
$label

pDereferenceLhs()

pDereferenceLhs(\PhpParser\Node  $node) 

Parameters

\PhpParser\Node $node

pCallLhs()

pCallLhs(\PhpParser\Node  $node) 

Parameters

\PhpParser\Node $node

hasNodeWithComments()

hasNodeWithComments(array  $nodes) 

Parameters

array $nodes

pMaybeMultiline()

pMaybeMultiline(array  $nodes,   $trailingComma = false) 

Parameters

array $nodes
$trailingComma