Properties

$value

$value : mixed

Type

mixed

$escaped

$escaped : boolean

Type

boolean

$sourceLocation

$sourceLocation : 

Type

$outerNode

$outerNode : 

Type

$token

$token : 

Type

$level

$level : 

Type

$parent

$parent : \Phug\Ast\NodeInterface

Stores the current parent node of this node.

Type

\Phug\Ast\NodeInterface

$children

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

Stores an array of children that are attached to this node.

Type

array<mixed,\Phug\Ast\NodeInterface>

$indent

$indent : 

Type

Methods

getValue()

getValue() : mixed

Returns

mixed

hasStaticValue()

hasStaticValue() : boolean

Returns

boolean

setValue()

setValue(mixed  $value) : $this

Parameters

mixed $value

Returns

$this

isEscaped()

isEscaped() : boolean

Returns

boolean

setIsEscaped()

setIsEscaped(boolean  $escaped) : $this

Parameters

boolean $escaped

Returns

$this

escape()

escape() : $this

Returns

$this

unescape()

unescape() : $this

Returns

$this

__construct()

__construct(\Phug\Ast\NodeInterface  $parent = null, array  $children = null) 

Creates a new node instance.

Parameters

\Phug\Ast\NodeInterface $parent
array $children

setOuterNode()

setOuterNode(\Phug\Parser\NodeInterface  $node = null) : $this

Parameters

\Phug\Parser\NodeInterface $node

Returns

$this

getLevel()

getLevel() 

__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 = 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.

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  $children) : mixed

Replaces all children with new ones.

This will remove all nodes from the current node.

Parameters

array $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>

getIterator()

getIterator() 

{@inheritdoc}

count()

count() 

{@inheritdoc}

offsetExists()

offsetExists(  $offset) 

{@inheritdoc}

Parameters

$offset

offsetGet()

offsetGet(  $offset) 

{@inheritdoc}

Parameters

$offset

offsetSet()

offsetSet(  $offset,   $value) 

{@inheritdoc}

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

{@inheritdoc}

Parameters

$offset

setIndent()

setIndent(  $indent) 

Parameters

$indent

getIndent()

getIndent() 

setLevel()

setLevel(  $level) 

Parameters

$level

prepareChild()

prepareChild(\Phug\Ast\NodeInterface  $child) 

{@inheritdoc}

Parameters

\Phug\Ast\NodeInterface $child

finishChild()

finishChild(\Phug\Ast\NodeInterface  $child) 

{@inheritdoc}

Parameters

\Phug\Ast\NodeInterface $child