PHP 클래스 Tale\Jade\Parser\Node

A node has children and always tries to reference its parents It also has some utility methods to work with those nodes
파일 보기 프로젝트 열기: talesoft/tale-jade 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$children Node[] The children of this node.
$line integer | null The line this node was created on.
$offset integer | null The offset in a line this node was created on.
$parent Node | null The parent-node of this node.
$type string The type of the node, can be a string of any kind.

공개 메소드들

메소드 설명
__construct ( string $type, integer | null $line = null, integer | null $offset = null ) Creates a new, detached node without children or a parent.
__debugInfo ( )
__get ( string $key ) : mixed Gets called when a property is read from this node.
__isset ( string $key ) : boolean Gets called when isset() is called on this node's properties.
__set ( string $key, mixed $value ) Gets called when a property is written on this node instance.
__toString ( ) : string Gets called when this node instance is casted to a string in any way
__unset ( string $key ) Gets called when unset() is called on this node's properties.
append ( Node $node ) Appends the given node to this node's children.
dump ( integer $level ) : string Dumps the node as a string to ease up debugging.
find ( string $type ) : Generator Finds nodes with the given type inside this nodes children.
findArray ( string $type ) : array Finds nodes with the given type inside this nodes children.
indexOf ( Node $node ) : integer | false Returns the position of the given node inside this node.
insertAfter ( Node $node, Node $newNode ) Inserts the second given node after the first given node inside this node's children.
insertBefore ( Node $node, Node $newNode ) Inserts the second given node before the first given node inside this node's children.
next ( ) : Node | null Returns the next sibling of this element or null, if if there isn't any.
prepend ( Node $node ) Prepends the given node to this node's children.
prev ( ) : Node | null Returns the previous sibling of this element or null, if if there isn't any.
remove ( Node $node ) Removes the given child node from this node's children.
text ( string $indentStyle = ' ', string $newLine = " ", integer $level ) : string Returns all text and child-texts in a single text.

메소드 상세

__construct() 공개 메소드

It can be appended to any node after that The type can be any kind of string
public __construct ( string $type, integer | null $line = null, integer | null $offset = null )
$type string the type of this node
$line integer | null the line at which we found this node
$offset integer | null the offset in a line we found this node at

__debugInfo() 공개 메소드

public __debugInfo ( )

__get() 공개 메소드

Redirects to the $_data storage and returns a reference to that value
public __get ( string $key ) : mixed
$key string the name of the property that is read
리턴 mixed a reference to the value of the property

__isset() 공개 메소드

Redirects the call to the $_data storage
public __isset ( string $key ) : boolean
$key string the name of the property to check
리턴 boolean

__set() 공개 메소드

Redirects to the $_data storage and sets a key with that value there
public __set ( string $key, mixed $value )
$key string the name of the property to be written
$value mixed the value of that property

__toString() 공개 메소드

(echo, (string), strval, string operations, ., etc.) Calls ->dump() and dumps a debuggable text-representation of this node and all of its child-nodes
public __toString ( ) : string
리턴 string a debuggable text-representation of this node tree

__unset() 공개 메소드

Redirects the call to $_data storage
public __unset ( string $key )
$key string the name of the property to unset

append() 공개 메소드

This also sets the parent of the given child to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->append([element:d]) [element:a] (0)[element:b] (1)[element:c] (2)[element:d]
public append ( Node $node )
$node Node the new child node to be appended

dump() 공개 메소드

This is also the default-action for __toString on every node The result will look like this: [element tag=a expands=[element tag=b]] [element tag=c attributes={[attribute name=d name=e]}]
public dump ( integer $level ) : string
$level integer the initial indentation level
리턴 string the string to debug the node-tree

find() 공개 메소드

Plus all it's children-children recursively and returns a generator providing them This is used to collect all blocks, imports and mixins and handle them in a special way If you need a normal array, use ->findArray() instead instead
public find ( string $type ) : Generator
$type string the node type to search for
리턴 Generator a generator of the found children

findArray() 공개 메소드

Plus all it's children-children recursively and returns an array with all of them I you want to do further searching on it, you should rather use the Generator-version ->find() to improve memory-usage
public findArray ( string $type ) : array
$type string the node type to search for
리턴 array an array containing all found children

indexOf() 공개 메소드

[element:a] (0)[element:b] (1)[element:c] (2)[element:d] [element:a]->indexOf([element:d]) === 2
또한 보기: array_search
public indexOf ( Node $node ) : integer | false
$node Node the child-node to get the index of
리턴 integer | false

insertAfter() 공개 메소드

This allows fine control over the node's children The new nodes parent will be set to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->insertAfter([element:b], [element:d]) [element:a] (0)[element:b] (1)[element:d] (2)[element:c]
public insertAfter ( Node $node, Node $newNode )
$node Node the child node of this node's children the new node will be inserted after
$newNode Node the new node that will be inserted after the first node

insertBefore() 공개 메소드

This allows fine control over the node's children The new nodes parent will be set to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->insertBefore([element:c], [element:d]) [element:a] (0)[element:b] (1)[element:d] (2)[element:c]
public insertBefore ( Node $node, Node $newNode )
$node Node the child node of this node's children the new node will be inserted before
$newNode Node the new node that will be inserted before the first node

next() 공개 메소드

[element:a] (0)[element:b] (1)[element:c] [element:b]->next() === [element:c]
public next ( ) : Node | null
리턴 Node | null

prepend() 공개 메소드

This also sets the parent of the given child to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->prepend([element:d]) [element:a] (0)[element:d] (1)[element:b] (2)[element:c]
public prepend ( Node $node )
$node Node the new child node to be prepended

prev() 공개 메소드

[element:a] (0)[element:b] (1)[element:c] [element:c]->prev() === [element:b]
public prev ( ) : Node | null
리턴 Node | null

remove() 공개 메소드

The parent of the given child node will be set to null [element:a] (0)[element:b] (1)[element:c] (2)[element:d] [element:a]->remove([element:c]) [element:a] (0)[element:b] (1)[element:d]
public remove ( Node $node )
$node Node the node to remove from this node's children

text() 공개 메소드

You can control the text-style with the arguments
public text ( string $indentStyle = ' ', string $newLine = " ", integer $level ) : string
$indentStyle string the indentation to use (multiplies with level)
$newLine string the new-line style to use
$level integer the initial indentation level
리턴 string the compiled text-block

프로퍼티 상세

$children 공개적으로 프로퍼티

The children of this node.
public Node[],Tale\Jade\Parser $children
리턴 Node[]

$line 공개적으로 프로퍼티

The line this node was created on.
public int|null $line
리턴 integer | null

$offset 공개적으로 프로퍼티

The offset in a line this node was created on.
public int|null $offset
리턴 integer | null

$parent 공개적으로 프로퍼티

The parent-node of this node.
public Node,Tale\Jade\Parser|null $parent
리턴 Node | null

$type 공개적으로 프로퍼티

The type of the node, can be a string of any kind.
public string $type
리턴 string