54 return sprintf(
'%s(%s)', self::typeToString($this->type,
true), $this->value);
72 if (null === $values && !is_int(
$type)) {
74 $type = self::NAME_TYPE;
77 return ($this->type ===
$type) && (
79 (is_array($values) && in_array($this->value, $values)) ||
80 $this->value == $values
122 case self::TEXT_TYPE:
125 case self::BLOCK_START_TYPE:
126 $name =
'BLOCK_START_TYPE';
128 case self::VAR_START_TYPE:
129 $name =
'VAR_START_TYPE';
131 case self::BLOCK_END_TYPE:
132 $name =
'BLOCK_END_TYPE';
134 case self::VAR_END_TYPE:
135 $name =
'VAR_END_TYPE';
137 case self::NAME_TYPE:
140 case self::NUMBER_TYPE:
141 $name =
'NUMBER_TYPE';
143 case self::STRING_TYPE:
144 $name =
'STRING_TYPE';
146 case self::OPERATOR_TYPE:
147 $name =
'OPERATOR_TYPE';
149 case self::PUNCTUATION_TYPE:
150 $name =
'PUNCTUATION_TYPE';
152 case self::INTERPOLATION_START_TYPE:
153 $name =
'INTERPOLATION_START_TYPE';
155 case self::INTERPOLATION_END_TYPE:
156 $name =
'INTERPOLATION_END_TYPE';
162 return $short ?
$name :
'Twig_Token::'.$name;
176 return 'end of template';
177 case self::TEXT_TYPE:
179 case self::BLOCK_START_TYPE:
180 return 'begin of statement block';
181 case self::VAR_START_TYPE:
182 return 'begin of print statement';
183 case self::BLOCK_END_TYPE:
184 return 'end of statement block';
185 case self::VAR_END_TYPE:
186 return 'end of print statement';
187 case self::NAME_TYPE:
189 case self::NUMBER_TYPE:
191 case self::STRING_TYPE:
193 case self::OPERATOR_TYPE:
195 case self::PUNCTUATION_TYPE:
196 return 'punctuation';
197 case self::INTERPOLATION_START_TYPE:
198 return 'begin of string interpolation';
199 case self::INTERPOLATION_END_TYPE:
200 return 'end of string interpolation';
207 class_alias(
'Twig_Token',
'Twig\Token',
false);
test($type, $values=null)
Tests the current token for a type and/or a value.
static typeToString($type, $short=false)
Returns the constant representation (internal) of a given type.
__construct($type, $value, $lineno)
const INTERPOLATION_END_TYPE
static typeToEnglish($type)
Returns the English representation of a given type.
const INTERPOLATION_START_TYPE