Properties

$options

$options : \ArrayObject

Type

\ArrayObject

$optionNameHandlers

$optionNameHandlers : array

Type

array

$level

$level : integer

Type

integer

$tokens

$tokens : \Iterator

The Iterator returned by the ->lex() method of the lexer.

Type

\Iterator

$parentNode

$parentNode : \Phug\Parser\Node

The parent that currently found childs are appended to.

When an -token is encountered, it moves one parent up ($_currentParent->parent becomes the new $_currentParent)

Type

\Phug\Parser\Node

$currentNode

$currentNode : \Phug\Parser\Node

The current element in the queue.

Will be appended to $_currentParent when a -token is encountered It will become the current parent, if an -token is encountered

Type

\Phug\Parser\Node

$lastNode

$lastNode : \Phug\Parser\Node

The last element that was completely put together.

Will be set on a -token ($_current will become last)

Type

\Phug\Parser\Node

$outerNode

$outerNode : \Phug\Parser\Node

Stores an expanded node to attach it to the expanding node later.

Type

\Phug\Parser\Node

$namedHandlers

$namedHandlers : array

Stores handlers by names.

Type

array

$interpolationStack

$interpolationStack : \SplObjectStorage

Stack of interpolation to enter/leave.

Type

\SplObjectStorage

$interpolationNodes

$interpolationNodes : array

Stack of interpolation base nodes.

Type

array

Methods

getOptions()

getOptions() 

{@inheritdoc}

setOptions()

setOptions(  $options) 

{@inheritdoc}

Parameters

$options

setOptionsRecursive()

setOptionsRecursive(  $options) 

{@inheritdoc}

Parameters

$options

setOptionsDefaults()

setOptionsDefaults(  $options = null) 

{@inheritdoc}

Parameters

$options

hasOption()

hasOption(  $name) 

{@inheritdoc}

Parameters

$name

getOption()

getOption(  $name) 

{@inheritdoc}

Parameters

$name

setOption()

setOption(  $name,   $value) 

{@inheritdoc}

Parameters

$name
$value

unsetOption()

unsetOption(  $name) 

{@inheritdoc}

Parameters

$name

addOptionNameHandlers()

addOptionNameHandlers(callable  $handler) 

Parameters

callable $handler

resetOptions()

resetOptions() 

getEventListeners()

getEventListeners() : array<mixed,\Phug\Event\ListenerQueue>

Returns current event listeners by event name.

Returns

array<mixed,\Phug\Event\ListenerQueue>

mergeEventListeners()

mergeEventListeners(array<mixed,\Phug\Event\ListenerQueue>|\Phug\EventManagerInterface  $eventListeners) : boolean

Merge current events listeners with a given list.

Parameters

array<mixed,\Phug\Event\ListenerQueue>|\Phug\EventManagerInterface $eventListeners

event listeners by event name

Returns

boolean —

true on success false on failure

attach()

attach(string  $event, callable  $callback, integer  $priority) : boolean

Attaches a listener to an event.

Parameters

string $event

the event to attach too

callable $callback

a callable function

integer $priority

the priority at which the $callback executed

Returns

boolean —

true on success false on failure

detach()

detach(string  $event, callable  $callback) : boolean

Detaches a listener from an event.

Parameters

string $event

the event to attach too

callable $callback

a callable function

Returns

boolean —

true on success false on failure

clearListeners()

clearListeners(string  $event) : void

Clear all listeners for a given event.

Parameters

string $event

trigger()

trigger(string|\Phug\EventInterface  $event, object|string  $target = null, array|object  $argv = array()) : mixed

Trigger an event.

Can accept an EventInterface or will create one if not passed

Parameters

string|\Phug\EventInterface $event
object|string $target
array|object $argv

Returns

mixed

__construct()

__construct(\Phug\Parser  $parser, \Iterator  $tokens, array  $options = null) 

Parameters

\Phug\Parser $parser
\Iterator $tokens
array $options

pushInterpolationNode()

pushInterpolationNode(\Phug\Parser\NodeInterface  $node) : integer

Parameters

\Phug\Parser\NodeInterface $node

Returns

integer

getParser()

getParser() : \Phug\Parser

Returns

\Phug\Parser

getLevel()

getLevel() : integer

Returns

integer

setLevel()

setLevel(integer  $level) : $this

Parameters

integer $level

Returns

$this

getTokens()

getTokens() : \Iterator

Returns

\Iterator

setTokens()

setTokens(\Iterator  $tokens) : $this

Parameters

\Iterator $tokens

Returns

$this

setParentNode()

setParentNode(\Phug\Parser\Node  $currentParent) : $this

Parameters

\Phug\Parser\Node $currentParent

Returns

$this

setCurrentNode()

setCurrentNode(\Phug\Parser\Node  $current) : $this

Parameters

\Phug\Parser\Node $current

Returns

$this

append()

append(\Phug\Parser\Node  $node) : $this

Append to current node, or set as current if node selected.

Parameters

\Phug\Parser\Node $node

Returns

$this

setLastNode()

setLastNode(\Phug\Parser\Node  $last) : $this

Parameters

\Phug\Parser\Node $last

Returns

$this

setOuterNode()

setOuterNode(\Phug\Parser\Node  $node) : $this

Parameters

\Phug\Parser\Node $node

Returns

$this

handleToken()

handleToken(\Phug\Lexer\TokenInterface  $token = null) : $this

Handles any kind of token returned by the lexer.

The token handler is translated according to the token_handlers option

If no token is passed, it will take the current token in the lexer's token generator

Parameters

\Phug\Lexer\TokenInterface $token

a token or the current lexer's generator token

Throws

\Phug\ParserException

when no token handler has been found

Returns

$this

lookUp()

lookUp(array  $types) : \Generator

Yields tokens as long as the given types match.

Yields tokens of the given types until a token is encountered, that is not given in the types-array

Parameters

array $types

the token types that are allowed

Returns

\Generator

lookUpNext()

lookUpNext(array  $types) : \Generator

Moves on the token generator by one and does ->lookUp().

Parameters

array $types

the types that are allowed

Returns

\Generator

expect()

expect(array  $types) : \Phug\Parser\Node|null

Returns the token of the given type if it is in the token queue.

If the given token in the queue is not of the given type, this method returns null

Parameters

array $types

the types that are expected

Returns

\Phug\Parser\Node|null

expectNext()

expectNext(array  $types) : \Phug\Parser\Node|null

Moves the generator on by one and does ->expect().

Parameters

array $types

the types that are expected

Returns

\Phug\Parser\Node|null

hasTokens()

hasTokens() : boolean

Returns true, if there are still tokens left to be generated.

If the lexer-generator still has tokens to generate, this returns true and false, if it doesn't

Returns

boolean

nextToken()

nextToken() : $this

Moves the generator on by one token.

(It calls ->next() on the generator, look at the PHP doc)

Returns

$this

getToken()

getToken() : array

Returns the current token in the lexer generator.

Returns

array —

the token array (always one token, as an array)

is()

is(\Phug\Parser\Node  $node, array  $classNames) 

Parameters

\Phug\Parser\Node $node
array $classNames

currentNodeIs()

currentNodeIs(array  $classNames) 

Parameters

array $classNames

lastNodeIs()

lastNodeIs(array  $classNames) 

Parameters

array $classNames

parentNodeIs()

parentNodeIs(array  $classNames) 

Parameters

array $classNames

createNode()

createNode(string  $className, \Phug\Lexer\TokenInterface  $token = null) : \Phug\Parser\Node

Creates a new node instance with the given type.

If a token is given, the location in the code of that token is also passed to the Node instance

If no token is passed, a dummy-token with the current lexer's offset and line is created

Notice that nodes are expando-objects, you can add properties on-the-fly and retrieve them as an array later

Parameters

string $className

the type the node should have

\Phug\Lexer\TokenInterface $token

the token to relate this node to

Returns

\Phug\Parser\Node

The newly created node

enter()

enter() 

leave()

leave() 

getInterpolationStack()

getInterpolationStack() : \SplObjectStorage

Returns

\SplObjectStorage

store()

store() 

throwException()

throwException(string  $message, integer  $code, \Phug\Lexer\TokenInterface  $relatedToken = null, null  $previous = null) 

Throws a parser-exception.

The current line and offset of the exception get automatically appended to the message

Parameters

string $message

A meaningful error message

integer $code
\Phug\Lexer\TokenInterface $relatedToken
null $previous

Throws

\Phug\ParserException

handleOptionName()

handleOptionName(string  $name) : string

Parameters

string $name

Returns

string

isTraversable()

isTraversable(  $value) 

Parameters

$value

filterTraversable()

filterTraversable(  $values) 

Parameters

$values

setOptionArrays()

setOptionArrays(array  $arrays, string  $functionName) : $this

Parameters

array $arrays
string $functionName

Returns

$this

setDefaultOption()

setDefaultOption(  $key,   $value) 

Parameters

$key
$value

withVariableReference()

withVariableReference(mixed  $variable,   $name, callable  $callback) : \Phug\Util\Partial\&$options

Parameters

mixed $variable
$name
callable $callback

Returns

\Phug\Util\Partial\&$options

withOptionReference()

withOptionReference(  $name, callable  $callback) : \Phug\Util\Partial\&$options

Parameters

$name
callable $callback

Returns

\Phug\Util\Partial\&$options

getNamedHandler()

getNamedHandler(string  $handler) : \Phug\Parser\TokenHandlerInterface

Instanciate a new handler by name or return the previous instancied one with the same name.

Parameters

string $handler

name

Returns

\Phug\Parser\TokenHandlerInterface