Guides

TreeNode
in package

FinalYes
Tags
template-covariant

of Node

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

$attachedNodes

private self[] $attachedNodes = []

children stored in registered fields, rather than as ordinary 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

$parent

private self|self|null $parent = null

Methods

findPosition()

public findPosition(Node $node) : int|null
Parameters
$node : Node
Return values
int|null

getNode()

public getNode() : TNode
Return values
TNode

getParent()

public getParent() : self|self|null
Return values
self|self|null

getRoot()

public getRoot() : self
Return values
self

getTraversalChildren()

Returns the nodes stored in registered fields, followed by the ordinary children.

public getTraversalChildren() : self[]
Return values
self[]

isLastChildOfParent()

public isLastChildOfParent() : bool
Return values
bool

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

replaceChild()

public replaceChild(Node $oldChildNode, Node $newChildNode) : void
Parameters
$oldChildNode : Node
$newChildNode : Node

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
self|null

keyOf()

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
Return values
int|string|null
On this page

Search results