ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Test.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
12{
13 public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
14 {
15 $nodes = array('node' => $node);
16 if (null !== $arguments) {
17 $nodes['arguments'] = $arguments;
18 }
19
20 parent::__construct($nodes, array('name' => $name), $lineno);
21 }
22
23 public function compile(Twig_Compiler $compiler)
24 {
25 $name = $this->getAttribute('name');
26 $test = $compiler->getEnvironment()->getTest($name);
27
28 $this->setAttribute('name', $name);
29 $this->setAttribute('type', 'test');
30 $this->setAttribute('thing', $test);
31 if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
32 $this->setAttribute('callable', $test->getCallable());
33 }
34 if ($test instanceof Twig_SimpleTest) {
35 $this->setAttribute('is_variadic', $test->isVariadic());
36 }
37
38 $this->compileCallable($compiler);
39 }
40}
41
42class_alias('Twig_Node_Expression_Test', 'Twig\Node\Expression\TestExpression', false);
$test
Definition: Utf8Test.php:84
An exception for terminatinating execution or to throw for unit testing.
Compiles a node to PHP code.
Definition: Compiler.php:19
getEnvironment()
Returns the environment instance related to this compiler.
Definition: Compiler.php:50
compileCallable(Twig_Compiler $compiler)
Definition: Call.php:15
__construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments=null, $lineno)
Definition: Test.php:13
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
Definition: Test.php:23
getAttribute($name)
Definition: Node.php:152
$lineno
Definition: Node.php:22
setAttribute($name, $value)
Definition: Node.php:165
$nodes
Definition: Node.php:20
Represents a template test.
Definition: SimpleTest.php:20
Represents a node in the AST.
Represents a callable template test.