protected function Twig_Extension_Core::getTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/Extension/Core.php \Twig_Extension_Core::getTest()
1 call to Twig_Extension_Core::getTest()
- Twig_Extension_Core::parseTestExpression in vendor/
twig/ twig/ lib/ Twig/ Extension/ Core.php
File
- vendor/
twig/ twig/ lib/ Twig/ Extension/ Core.php, line 297
Class
Code
protected function getTest(Twig_Parser $parser, $line) {
$stream = $parser
->getStream();
$name = $stream
->expect(Twig_Token::NAME_TYPE)
->getValue();
$env = $parser
->getEnvironment();
if ($test = $env
->getTest($name)) {
return array(
$name,
$test,
);
}
if ($stream
->test(Twig_Token::NAME_TYPE)) {
// try 2-words tests
$name = $name . ' ' . $parser
->getCurrentToken()
->getValue();
if ($test = $env
->getTest($name)) {
$parser
->getStream()
->next();
return array(
$name,
$test,
);
}
}
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $parser
->getFilename());
$e
->addSuggestions($name, array_keys($env
->getTests()));
throw $e;
}