NodeDumper
in package
Table of Contents
Constants
- IGNORE_ATTRIBUTES = ['comments' => true, 'startLine' => true, 'endLine' => true, 'startFilePos' => true, 'endFilePos' => true, 'startTokenPos' => true, 'endTokenPos' => true]
Properties
- $code : string|null
- $dumpComments : bool
- $dumpOtherAttributes : bool
- $dumpPositions : bool
- $nl : string
- $res : string
Methods
- __construct() : mixed
- Constructs a NodeDumper.
- dump() : string
- Dumps a node or array.
- dumpFlags() : string
- dumpPosition() : string|null
- Dump node position, if possible.
- dumpRecursive() : void
- dumpArrayKind() : string
- dumpEnum() : string
- dumpIncludeType() : string
- dumpIntKind() : string
- dumpListKind() : string
- dumpStringKind() : string
- dumpUseType() : string
- toColumn() : int
Constants
IGNORE_ATTRIBUTES
private
mixed
IGNORE_ATTRIBUTES
= ['comments' => true, 'startLine' => true, 'endLine' => true, 'startFilePos' => true, 'endFilePos' => true, 'startTokenPos' => true, 'endTokenPos' => true]
Properties
$code
private
string|null
$code
$dumpComments
private
bool
$dumpComments
$dumpOtherAttributes
private
bool
$dumpOtherAttributes
$dumpPositions
private
bool
$dumpPositions
$nl
private
string
$nl
$res
private
string
$res
Methods
__construct()
Constructs a NodeDumper.
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Supported options:
- bool dumpComments: Whether comments should be dumped.
- bool dumpPositions: Whether line/offset information should be dumped. To dump offset information, the code needs to be passed to dump().
- bool dumpOtherAttributes: Whether non-comment, non-position attributes should be dumped.
Parameters
- $options : array<string|int, mixed> = []
-
Options (see description)
dump()
Dumps a node or array.
public
dump(array<string|int, mixed>|Node $node[, string|null $code = null ]) : string
Parameters
- $node : array<string|int, mixed>|Node
-
Node or array to dump
- $code : string|null = null
-
Code corresponding to dumped AST. This only needs to be passed if the dumpPositions option is enabled and the dumping of node offsets is desired.
Return values
string —Dumped value
dumpFlags()
protected
dumpFlags(int $flags) : string
Parameters
- $flags : int
Return values
stringdumpPosition()
Dump node position, if possible.
protected
dumpPosition(Node $node) : string|null
Parameters
- $node : Node
-
Node for which to dump position
Return values
string|null —Dump of position, or null if position information not available
dumpRecursive()
protected
dumpRecursive(mixed $node[, bool $indent = true ]) : void
Parameters
- $node : mixed
- $indent : bool = true
dumpArrayKind()
private
dumpArrayKind(int $kind) : string
Parameters
- $kind : int
Return values
stringdumpEnum()
private
dumpEnum(int $value, array<int, string> $map) : string
Parameters
- $value : int
- $map : array<int, string>
Return values
stringdumpIncludeType()
private
dumpIncludeType(int $type) : string
Parameters
- $type : int
Return values
stringdumpIntKind()
private
dumpIntKind(int $kind) : string
Parameters
- $kind : int
Return values
stringdumpListKind()
private
dumpListKind(int $kind) : string
Parameters
- $kind : int
Return values
stringdumpStringKind()
private
dumpStringKind(int $kind) : string
Parameters
- $kind : int
Return values
stringdumpUseType()
private
dumpUseType(int $type) : string
Parameters
- $type : int
Return values
stringtoColumn()
private
toColumn(string $code, int $pos) : int
Parameters
- $code : string
- $pos : int