PHP Class PhpParser\PrettyPrinterAbstract

Afficher le fichier Open project: nikic/php-parser Class Usage Examples

Protected Properties

Свойство Type Description
$canUseSemicolonNamespaces
$docStringEndToken
$noIndentToken
$options
$precedenceMap

Méthodes publiques

Méthode Description
__construct ( array $options = [] ) Creates a pretty printer instance using the given options.
prettyPrint ( array $stmts ) : string Pretty prints an array of statements.
prettyPrintExpr ( PhpParser\Node\Expr $node ) : string Pretty prints an expression.
prettyPrintFile ( array $stmts ) : string Pretty prints a file of statements (includes the opening

Méthodes protégées

Méthode Description
handleMagicTokens ( $str )
p ( phpparser\Node $node ) : string Pretty prints a node.
pCommaSeparated ( array $nodes ) : string Pretty prints an array of nodes and implodes the printed values with commas.
pComments ( array $comments ) : string Prints reformatted text of the passed comments.
pImplode ( array $nodes, string $glue = '' ) : string Pretty prints an array of nodes and implodes the printed values.
pInfixOp ( $type, phpparser\Node $leftNode, $operatorString, phpparser\Node $rightNode )
pNoIndent ( string $string ) : string Signals the pretty printer that a string shall not be indented.
pPostfixOp ( $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.
pPrefixOp ( $type, $operatorString, phpparser\Node $node )
pStmts ( array $nodes, boolean $indent = true ) : string Pretty prints an array of nodes (statements) and indents them optionally.
preprocessNodes ( array $nodes ) Preprocesses the top-level nodes to initialize pretty printer state.

Method Details

__construct() public méthode

Supported options: * bool $shortArraySyntax = false: Whether to use [] instead of array() as the default array syntax, if the node does not specify a format.
public __construct ( array $options = [] )
$options array Dictionary of formatting options

handleMagicTokens() protected méthode

protected handleMagicTokens ( $str )

p() protected méthode

Pretty prints a node.
protected p ( phpparser\Node $node ) : string
$node phpparser\Node Node to be pretty printed
Résultat string Pretty printed node

pCommaSeparated() protected méthode

Pretty prints an array of nodes and implodes the printed values with commas.
protected pCommaSeparated ( array $nodes ) : string
$nodes array Array of Nodes to be printed
Résultat string Comma separated pretty printed nodes

pComments() protected méthode

Prints reformatted text of the passed comments.
protected pComments ( array $comments ) : string
$comments array List of comments
Résultat string Reformatted text of comments

pImplode() protected méthode

Pretty prints an array of nodes and implodes the printed values.
protected pImplode ( array $nodes, string $glue = '' ) : string
$nodes array Array of Nodes to be printed
$glue string Character to implode with
Résultat string Imploded pretty printed nodes

pInfixOp() protected méthode

protected pInfixOp ( $type, phpparser\Node $leftNode, $operatorString, phpparser\Node $rightNode )
$leftNode phpparser\Node
$rightNode phpparser\Node

pNoIndent() protected méthode

Signals the pretty printer that a string shall not be indented.
protected pNoIndent ( string $string ) : string
$string string Not to be indented string
Résultat string String marked with $this->noIndentToken's.

pPostfixOp() protected méthode

protected pPostfixOp ( $type, phpparser\Node $node, $operatorString )
$node phpparser\Node

pPrec() protected méthode

Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
protected pPrec ( phpparser\Node $node, integer $parentPrecedence, integer $parentAssociativity, integer $childPosition ) : string
$node phpparser\Node Node to pretty print
$parentPrecedence integer Precedence of the parent operator
$parentAssociativity integer Associativity of parent operator (-1 is left, 0 is nonassoc, 1 is right)
$childPosition integer Position of the node relative to the operator (-1 is left, 1 is right)
Résultat string The pretty printed node

pPrefixOp() protected méthode

protected pPrefixOp ( $type, $operatorString, phpparser\Node $node )
$node phpparser\Node

pStmts() protected méthode

Pretty prints an array of nodes (statements) and indents them optionally.
protected pStmts ( array $nodes, boolean $indent = true ) : string
$nodes array Array of nodes
$indent boolean Whether to indent the printed nodes
Résultat string Pretty printed statements

preprocessNodes() protected méthode

Preprocesses the top-level nodes to initialize pretty printer state.
protected preprocessNodes ( array $nodes )
$nodes array Array of nodes

prettyPrint() public méthode

Pretty prints an array of statements.
public prettyPrint ( array $stmts ) : string
$stmts array Array of statements
Résultat string Pretty printed statements

prettyPrintExpr() public méthode

Pretty prints an expression.
public prettyPrintExpr ( PhpParser\Node\Expr $node ) : string
$node PhpParser\Node\Expr Expression node
Résultat string Pretty printed node

prettyPrintFile() public méthode

Pretty prints a file of statements (includes the opening
public prettyPrintFile ( array $stmts ) : string
$stmts array Array of statements
Résultat string Pretty printed statements

Property Details

$canUseSemicolonNamespaces protected_oe property

protected $canUseSemicolonNamespaces

$docStringEndToken protected_oe property

protected $docStringEndToken

$noIndentToken protected_oe property

protected $noIndentToken

$options protected_oe property

protected $options

$precedenceMap protected_oe property

protected $precedenceMap