[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/twig/twig/src/Node/Expression/ -> FunctionExpression.php (source)

   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   */
  11  
  12  namespace Twig\Node\Expression;
  13  
  14  use Twig\Compiler;
  15  use Twig\TwigFunction;
  16  
  17  class FunctionExpression extends CallExpression
  18  {
  19      public function __construct($name, \Twig_NodeInterface $arguments, $lineno)
  20      {
  21          parent::__construct(['arguments' => $arguments], ['name' => $name, 'is_defined_test' => false], $lineno);
  22      }
  23  
  24      public function compile(Compiler $compiler)
  25      {
  26          $name = $this->getAttribute('name');
  27          $function = $compiler->getEnvironment()->getFunction($name);
  28  
  29          $this->setAttribute('name', $name);
  30          $this->setAttribute('type', 'function');
  31          $this->setAttribute('thing', $function);
  32          $this->setAttribute('needs_environment', $function->needsEnvironment());
  33          $this->setAttribute('needs_context', $function->needsContext());
  34          $this->setAttribute('arguments', $function->getArguments());
  35          if ($function instanceof \Twig_FunctionCallableInterface || $function instanceof TwigFunction) {
  36              $callable = $function->getCallable();
  37              if ('constant' === $name && $this->getAttribute('is_defined_test')) {
  38                  $callable = 'twig_constant_is_defined';
  39              }
  40  
  41              $this->setAttribute('callable', $callable);
  42          }
  43          if ($function instanceof TwigFunction) {
  44              $this->setAttribute('is_variadic', $function->isVariadic());
  45          }
  46  
  47          $this->compileCallable($compiler);
  48      }
  49  }
  50  
  51  class_alias('Twig\Node\Expression\FunctionExpression', 'Twig_Node_Expression_Function');


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1