\Phug\FormatterAssignmentContainerInterface

Represents a node in a tree-like structure.

All methods should automatically keep a consistent state inside the tree, e.g. if $someNode->setParent(null) is done, the previous parent shouldn't have $someNode in its children anymore.

Summary

Methods
Constants
dump()
getOriginNode()
__clone()
hasParent()
getParent()
setParent()
hasChildren()
getChildCount()
getChildIndex()
getChildren()
setChildren()
removeChildren()
hasChild()
hasChildAt()
getChildAt()
removeChildAt()
appendChild()
prependChild()
removeChild()
insertBefore()
insertAfter()
getIndex()
getPreviousSibling()
getNextSibling()
append()
prepend()
remove()
is()
findChildren()
findChildrenArray()
find()
findArray()
getName()
addAssignment()
removedAssignment()
getAssignments()
getAssignmentsByName()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

dump()

dump() : string

Returns

string

__clone()

__clone() 

Creates a recursive, detached copy of the current node.

hasParent()

hasParent() : \Phug\Ast\NodeInterface

Checks if the current node has a parent-node.

Returns

\Phug\Ast\NodeInterface

getParent()

getParent() : \Phug\Ast\NodeInterface|null

Gets the currently associated parent-node.

If the node has no parent, null is returned.

Returns

\Phug\Ast\NodeInterface|null

setParent()

setParent(\Phug\Ast\NodeInterface  $parent) : $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.

Parameters

\Phug\Ast\NodeInterface $parent

Returns

$this

hasChildren()

hasChildren() : boolean

Returns `true` if this node has any children, `false` if not.

Returns

boolean

getChildCount()

getChildCount() : integer

Returns the amount of children attached to this node.

Returns

integer

getChildIndex()

getChildIndex(\Phug\Ast\NodeInterface  $child) : integer|false

Returns the numerical index of a child-node.

Parameters

\Phug\Ast\NodeInterface $child

Returns

integer|false

getChildren()

getChildren() : array<mixed,\Phug\Ast\NodeInterface>

Returns an array of child-nodes attached to this node.

Returns

array<mixed,\Phug\Ast\NodeInterface>

setChildren()

setChildren(array<mixed,\Phug\Ast\NodeInterface>  $children) : mixed

Replaces all children with new ones.

This will remove all nodes from the current node.

Parameters

array<mixed,\Phug\Ast\NodeInterface> $children

Returns

mixed

removeChildren()

removeChildren() : $this

Removes all children from this node.

All parents of the child-nodes are set to null respectively.

Returns

$this

hasChild()

hasChild(\Phug\Ast\NodeInterface  $child) : boolean

Checks if this node has a certain child among its children.

Parameters

\Phug\Ast\NodeInterface $child

Returns

boolean

hasChildAt()

hasChildAt(  $index) : boolean

Checks if this node has a child at a specified numerical index.

Parameters

$index

Returns

boolean

getChildAt()

getChildAt(  $index) : \Phug\Ast\NodeInterface

Gets a child at a specified numerical index.

Parameters

$index

Returns

\Phug\Ast\NodeInterface

removeChildAt()

removeChildAt(  $index) : $this

Removes a child at a specified numerical index.

Parameters

$index

Returns

$this

appendChild()

appendChild(\Phug\Ast\NodeInterface  $child) : $this

Appends a child to the child-list.

Parameters

\Phug\Ast\NodeInterface $child

Returns

$this

prependChild()

prependChild(\Phug\Ast\NodeInterface  $child) : $this

Prepends a child to the child-list.

Parameters

\Phug\Ast\NodeInterface $child

Returns

$this

removeChild()

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.

Parameters

\Phug\Ast\NodeInterface $child

Returns

$this

insertBefore()

insertBefore(\Phug\Ast\NodeInterface  $child, \Phug\Ast\NodeInterface  $newChild) : $this

Inserts a child before another child in the child-list.

Parameters

\Phug\Ast\NodeInterface $child
\Phug\Ast\NodeInterface $newChild

Returns

$this

insertAfter()

insertAfter(\Phug\Ast\NodeInterface  $child, \Phug\Ast\NodeInterface  $newChild) : $this

Inserts a child after another child in the child-list.

Parameters

\Phug\Ast\NodeInterface $child
\Phug\Ast\NodeInterface $newChild

Returns

$this

getIndex()

getIndex() : integer|false

Returns the numerical index of this child inside its parent.

Returns the index

Returns

integer|false

getPreviousSibling()

getPreviousSibling() : \Phug\Ast\NodeInterface

Gets the previous sibling of this child inside its parent.

Returns

\Phug\Ast\NodeInterface

getNextSibling()

getNextSibling() : \Phug\Ast\NodeInterface

Gets the next sibling of this child inside its parent.

Returns

\Phug\Ast\NodeInterface

append()

append(\Phug\Ast\NodeInterface  $child) : $this

Appends a child right after this node in its parent.

Parameters

\Phug\Ast\NodeInterface $child

Returns

$this

prepend()

prepend(\Phug\Ast\NodeInterface  $child) : $this

Prepends a child before this node in its parent.

Parameters

\Phug\Ast\NodeInterface $child

Returns

$this

remove()

remove() : $this

Removes/detaches this node from the tree.

Returns

$this

is()

is(callable  $callback) : boolean

Validates a child by a given callback.

The callback receives this node as the first parameter.

Parameters

callable $callback

Returns

boolean

findChildren()

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.

Parameters

callable $callback
integer $depth
integer $level

Returns

\Phug\Ast\iterable

findChildrenArray()

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.

Parameters

callable $callback
integer $depth
integer $level

Returns

array<mixed,\Phug\Ast\NodeInterface>

find()

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.

Parameters

callable $callback
integer $depth

Returns

\Phug\Ast\iterable

findArray()

findArray(callable  $callback, integer  $depth = null) : array<mixed,\Phug\Ast\NodeInterface>

Same as `find()`, but returns an iterated array instead of a generator.

Parameters

callable $callback
integer $depth

Returns

array<mixed,\Phug\Ast\NodeInterface>

getName()

getName() 

getAssignments()

getAssignments() 

getAssignmentsByName()

getAssignmentsByName(  $name) 

Parameters

$name