59 return sprintf(
'%s(%s)', self::typeToString($this->type,
true, $this->lineno), $this->value);
77 if (null === $values && !is_int(
$type)) {
79 $type = self::NAME_TYPE;
82 return ($this->type ===
$type) && (
84 (is_array($values) && in_array($this->value, $values)) ||
85 $this->value == $values
134 case self::TEXT_TYPE:
137 case self::BLOCK_START_TYPE:
138 $name =
'BLOCK_START_TYPE';
140 case self::VAR_START_TYPE:
141 $name =
'VAR_START_TYPE';
143 case self::BLOCK_END_TYPE:
144 $name =
'BLOCK_END_TYPE';
146 case self::VAR_END_TYPE:
147 $name =
'VAR_END_TYPE';
149 case self::NAME_TYPE:
152 case self::NUMBER_TYPE:
153 $name =
'NUMBER_TYPE';
155 case self::STRING_TYPE:
156 $name =
'STRING_TYPE';
158 case self::OPERATOR_TYPE:
159 $name =
'OPERATOR_TYPE';
161 case self::PUNCTUATION_TYPE:
162 $name =
'PUNCTUATION_TYPE';
164 case self::INTERPOLATION_START_TYPE:
165 $name =
'INTERPOLATION_START_TYPE';
167 case self::INTERPOLATION_END_TYPE:
168 $name =
'INTERPOLATION_END_TYPE';
171 throw new LogicException(sprintf(
'Token of type "%s" does not exist.',
$type));
174 return $short ? $name :
'Twig_Token::'.$name;
189 return 'end of template';
190 case self::TEXT_TYPE:
192 case self::BLOCK_START_TYPE:
193 return 'begin of statement block';
194 case self::VAR_START_TYPE:
195 return 'begin of print statement';
196 case self::BLOCK_END_TYPE:
197 return 'end of statement block';
198 case self::VAR_END_TYPE:
199 return 'end of print statement';
200 case self::NAME_TYPE:
202 case self::NUMBER_TYPE:
204 case self::STRING_TYPE:
206 case self::OPERATOR_TYPE:
208 case self::PUNCTUATION_TYPE:
209 return 'punctuation';
210 case self::INTERPOLATION_START_TYPE:
211 return 'begin of string interpolation';
212 case self::INTERPOLATION_END_TYPE:
213 return 'end of string interpolation';
215 throw new LogicException(sprintf(
'Token of type "%s" does not exist.',
$type));
static typeToString($type, $short=false, $line=-1)
Returns the constant representation (internal) of a given type.
const INTERPOLATION_END_TYPE
__construct($type, $value, $lineno)
Constructor.
static typeToEnglish($type, $line=-1)
Returns the english representation of a given type.
getType()
Gets the token type.
__toString()
Returns a string representation of the token.
const INTERPOLATION_START_TYPE
getValue()
Gets the token value.
test($type, $values=null)
Tests the current token for a type and/or a value.