public function Twig_Node_Expression_Test::compile in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/twig/twig/lib/Twig/Node/Expression/Test.php \Twig_Node_Expression_Test::compile()
Compiles the node to PHP.
Parameters
Twig_Compiler $compiler A Twig_Compiler instance:
Overrides Twig_Node::compile
7 methods override Twig_Node_Expression_Test::compile()
- Twig_Node_Expression_Test_Constant::compile in vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test/ Constant.php - Compiles the node to PHP.
- Twig_Node_Expression_Test_Defined::compile in vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test/ Defined.php - Compiles the node to PHP.
- Twig_Node_Expression_Test_Divisibleby::compile in vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test/ Divisibleby.php - Compiles the node to PHP.
- Twig_Node_Expression_Test_Even::compile in vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test/ Even.php - Compiles the node to PHP.
- Twig_Node_Expression_Test_Null::compile in vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test/ Null.php - Compiles the node to PHP.
File
- vendor/
twig/ twig/ lib/ Twig/ Node/ Expression/ Test.php, line 18
Class
Code
public function compile(Twig_Compiler $compiler) {
$name = $this
->getAttribute('name');
$test = $compiler
->getEnvironment()
->getTest($name);
$this
->setAttribute('name', $name);
$this
->setAttribute('type', 'test');
$this
->setAttribute('thing', $test);
if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
$this
->setAttribute('callable', $test
->getCallable());
}
if ($test instanceof Twig_SimpleTest) {
$this
->setAttribute('is_variadic', $test
->isVariadic());
}
$this
->compileCallable($compiler);
}