Class Twig_TokenStream

InheritanceTwig_TokenStream

Represents a token stream.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. Twig_TokenStream
__toString() Returns a string representation of the token stream. Twig_TokenStream
expect() Tests a token and returns it or throws a syntax error. Twig_TokenStream
getCurrent() Gets the current token. Twig_TokenStream
getFilename() Gets the filename associated with this stream (null if not defined). Twig_TokenStream
getSource() Gets the source code associated with this stream. Twig_TokenStream
injectTokens() Twig_TokenStream
isEOF() Checks if end of stream was reached. Twig_TokenStream
look() Looks at the next token. Twig_TokenStream
next() Sets the pointer to the next token and returns the old one. Twig_TokenStream
nextIf() Tests a token, sets the pointer to the next one and returns it or throws a syntax error. Twig_TokenStream
test() Tests the current token. Twig_TokenStream

Property Details

$current protected property
protected $current 0
$filename protected property
protected $filename null
$tokens protected property
protected $tokens null

Method Details

__construct() public method

Constructor.

public void __construct ( array $tokens, $filename null, $source null )
$tokens array

An array of tokens

$filename
$source
__toString() public method

Returns a string representation of the token stream.

public string __toString ( )
expect() public method

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

public Twig_Token expect ( $type, $value null, $message null )
$type
$value
$message
getCurrent() public method

Gets the current token.

public Twig_Token getCurrent ( )
getFilename() public method

Gets the filename associated with this stream (null if not defined).

public string|null getFilename ( )
getSource() public method

Gets the source code associated with this stream.

public string getSource ( )
injectTokens() public method

public void injectTokens ( array $tokens )
$tokens
isEOF() public method

Checks if end of stream was reached.

public bool isEOF ( )
look() public method

Looks at the next token.

public Twig_Token look ( $number 1 )
$number int
next() public method

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

public Twig_Token next ( )
nextIf() public method

Tests a token, sets the pointer to the next one and returns it or throws a syntax error.

public Twig_Token|null nextIf ( $primary, $secondary null )
$primary
$secondary
return Twig_Token|null

The next token if the condition is true, null otherwise

test() public method

Tests the current token.

public bool test ( $primary, $secondary null )
$primary
$secondary