Twig API
Class

Twig_TokenStream

class Twig_TokenStream

Represents a token stream.

Methods

__construct(array $tokens, string $filename = null)

Constructor.

string __toString()

Returns a string representation of the token stream.

injectTokens(array $tokens)

Twig_Token next()

Sets the pointer to the next token and returns the old one.

Twig_Token expect($type, $value = null, $message = null)

Tests a token and returns it or throws a syntax error.

Twig_Token look(integer $number = 1)

Looks at the next token.

bool test($primary, $secondary = null)

Tests the current token

bool isEOF()

Checks if end of stream was reached

Twig_Token getCurrent()

Gets the current token

string getFilename()

Gets the filename associated with this stream

Details

at line 30
public __construct(array $tokens, string $filename = null)

Constructor.

Parameters

array $tokens An array of tokens
string $filename The name of the filename which tokens are associated with

at line 42
public string __toString()

Returns a string representation of the token stream.

Return Value

string

at line 47
public injectTokens(array $tokens)

Parameters

array $tokens

at line 57
public Twig_Token next()

Sets the pointer to the next token and returns the old one.

Return Value

Twig_Token

at line 71
public Twig_Token expect($type, $value = null, $message = null)

Tests a token and returns it or throws a syntax error.

Parameters

$type
$value
$message

Return Value

Twig_Token

at line 96
public Twig_Token look(integer $number = 1)

Looks at the next token.

Parameters

integer $number

Return Value

Twig_Token

at line 110
public bool test($primary, $secondary = null)

Tests the current token

Parameters

$primary
$secondary

Return Value

bool

at line 120
public bool isEOF()

Checks if end of stream was reached

Return Value

bool

at line 130
public Twig_Token getCurrent()

Gets the current token

Return Value

Twig_Token

at line 140
public string getFilename()

Gets the filename associated with this stream

Return Value

string