public function Twig_TokenStream::expect in Translation template extractor 7.2
Same name and namespace in other branches
- 6.3 vendor/Twig/TokenStream.php \Twig_TokenStream::expect()
- 7.3 vendor/Twig/TokenStream.php \Twig_TokenStream::expect()
Tests a token and returns it or throws a syntax error.
Return value
File
- vendor/
Twig/ TokenStream.php, line 83
Class
- Twig_TokenStream
- Represents a token stream.
Code
public function expect($type, $value = null, $message = null) {
$token = $this->tokens[$this->current];
if (!$token
->test($type, $value)) {
$line = $token
->getLine();
throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message . '. ' : '', Twig_Token::typeToEnglish($token
->getType(), $line), $token
->getValue(), Twig_Token::typeToEnglish($type, $line), $value ? sprintf(' with value "%s"', $value) : ''), $line, $this->filename);
}
$this
->next();
return $token;
}