$sourceLocation
$sourceLocation :
Represents a node in the AST the parser generates.
A node has children and always tries to reference its parents
It also has some utility methods to work with those nodes
$parent : \Phug\Ast\NodeInterface
Stores the current parent node of this node.
$children : array<mixed,\Phug\Ast\NodeInterface>
Stores an array of children that are attached to this node.
__construct(\Phug\Ast\NodeInterface $parent = null, array $children = null)
Creates a new node instance.
\Phug\Ast\NodeInterface | $parent | |
array | $children |
getSourceLocation() : \Phug\Util\SourceLocationInterface|null
getOuterNode() : \Phug\Parser\NodeInterface
getToken() : \Phug\Lexer\TokenInterface
setOuterNode(\Phug\Parser\NodeInterface $node = null) : $this
\Phug\Parser\NodeInterface | $node |
hasParent() : \Phug\Ast\NodeInterface
Checks if the current node has a parent-node.
getParent() : \Phug\Ast\NodeInterface|null
Gets the currently associated parent-node.
If the node has no parent, null
is returned.
setParent(\Phug\Ast\NodeInterface $parent = null) : $this
Sets the nodes parent to a new one.
This will automatically remove it from the old parent, if any, and append it to the new one.
\Phug\Ast\NodeInterface | $parent |
getChildIndex(\Phug\Ast\NodeInterface $child) : integer|false
Returns the numerical index of a child-node.
\Phug\Ast\NodeInterface | $child |
getChildren() : array<mixed,\Phug\Ast\NodeInterface>
Returns an array of child-nodes attached to this node.
hasChild(\Phug\Ast\NodeInterface $child) : boolean
Checks if this node has a certain child among its children.
\Phug\Ast\NodeInterface | $child |
getChildAt( $index) : \Phug\Ast\NodeInterface
Gets a child at a specified numerical index.
$index |
appendChild(\Phug\Ast\NodeInterface $child) : $this
Appends a child to the child-list.
\Phug\Ast\NodeInterface | $child |
prependChild(\Phug\Ast\NodeInterface $child) : $this
Prepends a child to the child-list.
\Phug\Ast\NodeInterface | $child |
removeChild(\Phug\Ast\NodeInterface $child) : $this
Removes a child from the child-list.
This is detaching. The child and its own child-nodes are still intact, but it's detached from the tree completely and acts as an own root-node.
\Phug\Ast\NodeInterface | $child |
insertBefore(\Phug\Ast\NodeInterface $child, \Phug\Ast\NodeInterface $newChild) : $this
Inserts a child before another child in the child-list.
\Phug\Ast\NodeInterface | $child | |
\Phug\Ast\NodeInterface | $newChild |
insertAfter(\Phug\Ast\NodeInterface $child, \Phug\Ast\NodeInterface $newChild) : $this
Inserts a child after another child in the child-list.
\Phug\Ast\NodeInterface | $child | |
\Phug\Ast\NodeInterface | $newChild |
getPreviousSibling() : \Phug\Ast\NodeInterface
Gets the previous sibling of this child inside its parent.
getNextSibling() : \Phug\Ast\NodeInterface
Gets the next sibling of this child inside its parent.
append(\Phug\Ast\NodeInterface $child) : $this
Appends a child right after this node in its parent.
\Phug\Ast\NodeInterface | $child |
prepend(\Phug\Ast\NodeInterface $child) : $this
Prepends a child before this node in its parent.
\Phug\Ast\NodeInterface | $child |
findChildren(callable $callback, integer $depth = null, integer $level = null) : \Phug\Ast\iterable
Traverses the tree and returns all child elements that match the given callback.
This uses $this->is($callback)
internally.
This method is exclusive, it doesn't include this child in its checks.
callable | $callback | |
integer | $depth | |
integer | $level |
findChildrenArray(callable $callback, integer $depth = null, integer $level = null) : array<mixed,\Phug\Ast\NodeInterface>
Same as `findChildren()`, but returns an iterated array instead of a generator.
callable | $callback | |
integer | $depth | |
integer | $level |
find(callable $callback, integer $depth = null) : \Phug\Ast\iterable
Traverses the tree and returns all child elements that match the given callback.
This uses $this->is($callback)
internally.
This method is inclusive, it includes this child in its checks.
callable | $callback | |
integer | $depth |
findArray(callable $callback, integer $depth = null) : array<mixed,\Phug\Ast\NodeInterface>
Same as `find()`, but returns an iterated array instead of a generator.
callable | $callback | |
integer | $depth |
prepareChild(\Phug\Ast\NodeInterface $child)
{@inheritdoc}
\Phug\Ast\NodeInterface | $child |
finishChild(\Phug\Ast\NodeInterface $child)
{@inheritdoc}
\Phug\Ast\NodeInterface | $child |