ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Function.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($name, Twig_NodeInterface $arguments, $lineno)
14 {
15 parent::__construct(array('arguments' => $arguments), array('name' => $name, 'is_defined_test' => false), $lineno);
16 }
17
18 public function compile(Twig_Compiler $compiler)
19 {
20 $name = $this->getAttribute('name');
21 $function = $compiler->getEnvironment()->getFunction($name);
22
23 $this->setAttribute('name', $name);
24 $this->setAttribute('type', 'function');
25 $this->setAttribute('thing', $function);
26 $this->setAttribute('needs_environment', $function->needsEnvironment());
27 $this->setAttribute('needs_context', $function->needsContext());
28 $this->setAttribute('arguments', $function->getArguments());
29 if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) {
30 $callable = $function->getCallable();
31 if ('constant' === $name && $this->getAttribute('is_defined_test')) {
32 $callable = 'twig_constant_is_defined';
33 }
34
35 $this->setAttribute('callable', $callable);
36 }
37 if ($function instanceof Twig_SimpleFunction) {
38 $this->setAttribute('is_variadic', $function->isVariadic());
39 }
40
41 $this->compileCallable($compiler);
42 }
43}
44
45class_alias('Twig_Node_Expression_Function', 'Twig\Node\Expression\FunctionExpression', false);
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($name, Twig_NodeInterface $arguments, $lineno)
Definition: Function.php:13
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
Definition: Function.php:18
getAttribute($name)
Definition: Node.php:152
$lineno
Definition: Node.php:22
setAttribute($name, $value)
Definition: Node.php:165
Represents a template function.
Represents a callable template function.
Represents a node in the AST.