Class Twig_Token

InheritanceTwig_Token

Represents a Token.

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$lineno Twig_Token
$type Twig_Token
$value Twig_Token

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. Twig_Token
__toString() Returns a string representation of the token. Twig_Token
getLine() Gets the line. Twig_Token
getType() Gets the token type. Twig_Token
getValue() Gets the token value. Twig_Token
test() Tests the current token for a type and/or a value. Twig_Token
typeToEnglish() Returns the english representation of a given type. Twig_Token
typeToString() Returns the constant representation (internal) of a given type. Twig_Token

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
BLOCK_END_TYPE 3 Twig_Token
BLOCK_START_TYPE 1 Twig_Token
EOF_TYPE -1 Twig_Token
INTERPOLATION_END_TYPE 11 Twig_Token
INTERPOLATION_START_TYPE 10 Twig_Token
NAME_TYPE 5 Twig_Token
NUMBER_TYPE 6 Twig_Token
OPERATOR_TYPE 8 Twig_Token
PUNCTUATION_TYPE 9 Twig_Token
STRING_TYPE 7 Twig_Token
TEXT_TYPE 0 Twig_Token
VAR_END_TYPE 4 Twig_Token
VAR_START_TYPE 2 Twig_Token

Property Details

$lineno protected property
protected $lineno null
$type protected property
protected $type null
$value protected property
protected $value null

Method Details

__construct() public method

Constructor.

public void __construct ( $type, $value, $lineno )
$type int

The type of the token

$value string

The token value

$lineno int

The line position in the source

__toString() public method

Returns a string representation of the token.

public string __toString ( )
return string

A string representation of the token

getLine() public method

Gets the line.

public int getLine ( )
return int

The source line

getType() public method

Gets the token type.

public int getType ( )
return int

The token type

getValue() public method

Gets the token value.

public string getValue ( )
return string

The token value

test() public method

Tests the current token for a type and/or a value.

Parameters may be:

  • just type
  • type and value (or array of possible values)
  • just value (or array of possible values) (NAME_TYPE is used as type)
public bool test ( $type, $values null )
$type array|int

The type to test

$values array|string|null

The token value

typeToEnglish() public static method

Returns the english representation of a given type.

public static string typeToEnglish ( $type )
$type int

The type as an integer

return string

The string representation

typeToString() public static method

Returns the constant representation (internal) of a given type.

public static string typeToString ( $type, $short false )
$type int

The type as an integer

$short bool

Whether to return a short representation or not

return string

The string representation