TreeNode
in package
FinalYes
Tags
Table of Contents
Properties
- $attachedNodeRegistry : SubNodeAccessorRegistry
-
$attachedNodes
: self
[] -
$children
: self
[] - $field : SubNodeAccessor|null
- The field of the parent this node was extracted from, used to write changes back
- $key : int|string|null
- $node : TNode
-
$parent
: self
|self |null - $root : TreeNode<string|int, DocumentNode>
Methods
- addChild() : void
- createFromDocument() : TreeNode<string|int, DocumentNode>
- findPosition() : int|null
- getChildren() : TreeNode<string|int, Node>[]
- getNode() : TNode
-
getParent()
: self
|self |null -
getRoot()
: self
-
getTraversalChildren()
: self
[] - Returns the nodes stored in registered fields, followed by the ordinary children.
- isLastChildOfParent() : bool
- pushChild() : void
- release() : void
- Shadow trees are reference cycles (child to parent and to root), so without this they're only freed by the cycle collector, which also has to walk the whole AST.
- removeChild() : void
- replaceChild() : void
- __construct() : mixed
- changeNode() : void
- Stores the new version of this node, and writes it back to the field of its parent.
- createChildren() : void
- createFromNode() : TreeNode<string|int, TValue>
-
findEdge()
: self
|null - keyOf() : int|string|null
- Ordinary children shift when siblings are removed or pushed, so their index is derived from the current position. Other fields keep the key they were extracted with.
Properties
$attachedNodeRegistry read-only
private
SubNodeAccessorRegistry
$attachedNodeRegistry
= new SubNodeAccessorRegistry([])
$attachedNodes
private
self []
$attachedNodes
= []
children stored in registered fields, rather than as ordinary children
$children
private
self []
$children
= []
$field read-only
The field of the parent this node was extracted from, used to write changes back
private
SubNodeAccessor|null
$field
= null
$key
private
int|string|null
$key
= null
$node
private
TNode
$node
$parent
private
self |self |null
$parent
= null
$root
private
TreeNode<string|int, DocumentNode>
$root
Methods
addChild()
public
addChild(Node $child) : void
Parameters
- $child : Node
createFromDocument()
public
static createFromDocument(DocumentNode $document[, SubNodeAccessorRegistry|null $attachedNodeRegistry = null ]) : TreeNode<string|int, DocumentNode>
Parameters
- $document : DocumentNode
- $attachedNodeRegistry : SubNodeAccessorRegistry|null = null
Return values
TreeNode<string|int, DocumentNode>findPosition()
public
findPosition(Node $node) : int|null
Parameters
- $node : Node
Return values
int|nullgetChildren()
public
getChildren() : TreeNode<string|int, Node>[]
Return values
TreeNode<string|int, Node>[]getNode()
public
getNode() : TNode
Return values
TNodegetParent()
public
getParent() : self |self |null
Return values
selfgetRoot()
public
getRoot() : self
Return values
selfgetTraversalChildren()
Returns the nodes stored in registered fields, followed by the ordinary children.
public
getTraversalChildren() : self []
Return values
selfisLastChildOfParent()
public
isLastChildOfParent() : bool
Return values
boolpushChild()
public
pushChild(Node $child) : void
Parameters
- $child : Node
release()
Shadow trees are reference cycles (child to parent and to root), so without this they're only freed by the cycle collector, which also has to walk the whole AST.
public
release() : void
removeChild()
public
removeChild(Node $node) : void
Parameters
- $node : Node
replaceChild()
public
replaceChild(Node $oldChildNode, Node $newChildNode) : void
Parameters
__construct()
private
__construct(Node $node[, self|null $parent = null ][, SubNodeAccessorRegistry $attachedNodeRegistry = new SubNodeAccessorRegistry([]) ][, SubNodeAccessor|null $field = null ][, int|string|null $key = null ]) : mixed
Parameters
- $node : Node
- $parent : self|null = null
- $attachedNodeRegistry : SubNodeAccessorRegistry = new SubNodeAccessorRegistry([])
- $field : SubNodeAccessor|null = null
- $key : int|string|null = null
changeNode()
Stores the new version of this node, and writes it back to the field of its parent.
private
changeNode(Node $newNode) : void
Parameters
- $newNode : Node
createChildren()
private
createChildren() : void
createFromNode()
private
static createFromNode(TValue $node, self |self $parent, SubNodeAccessor $field[, int|string|null $key = null ]) : TreeNode<string|int, TValue>
Parameters
- $node : TValue
-
$parent
: self
|self - $field : SubNodeAccessor
- $key : int|string|null = null
Return values
TreeNode<string|int, TValue>findEdge()
private
findEdge(Node $node, string $action) : self |null
Parameters
- $node : Node
- $action : string
Return values
selfkeyOf()
Ordinary children shift when siblings are removed or pushed, so their index is derived from the current position. Other fields keep the key they were extracted with.
private
keyOf(self $child) : int|string|null
Parameters
-
$child
: self