Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

TwigFunction.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.30 KiB


001  <?php
002   
003  /*
004   * This file is part of Twig.
005   *
006   * (c) Fabien Potencier
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Twig;
013   
014  use Twig\Node\Expression\FunctionExpression;
015  use Twig\Node\Node;
016   
017  /**
018   * Represents a template function.
019   *
020   * @final
021   *
022   * @author Fabien Potencier <fabien@symfony.com>
023   *
024   * @see https://twig.symfony.com/doc/templates.html#functions
025   */
026  class TwigFunction
027  {
028      private $name;
029      private $callable;
030      private $options;
031      private $arguments = [];
032   
033      /**
034       * Creates a template function.
035       *
036       * @param string        $name     Name of this function
037       * @param callable|null $callable A callable implementing the function. If null, you need to overwrite the "node_class" option to customize compilation.
038       * @param array         $options  Options array
039       */
040      public function __construct(string $name, $callable = null, array $options = [])
041      {
042          if (__CLASS__ !== static::class) {
043              @trigger_error('Overriding '.__CLASS__.' is deprecated since Twig 2.4.0 and the class will be final in 3.0.', \E_USER_DEPRECATED);
044          }
045   
046          $this->name = $name;
047          $this->callable = $callable;
048          $this->options = array_merge([
049              'needs_environment' => false,
050              'needs_context' => false,
051              'is_variadic' => false,
052              'is_safe' => null,
053              'is_safe_callback' => null,
054              'node_class' => FunctionExpression::class,
055              'deprecated' => false,
056              'alternative' => null,
057          ], $options);
058      }
059   
060      public function getName()
061      {
062          return $this->name;
063      }
064   
065      /**
066       * Returns the callable to execute for this function.
067       *
068       * @return callable|null
069       */
070      public function getCallable()
071      {
072          return $this->callable;
073      }
074   
075      public function getNodeClass()
076      {
077          return $this->options['node_class'];
078      }
079   
080      public function setArguments($arguments)
081      {
082          $this->arguments = $arguments;
083      }
084   
085      public function getArguments()
086      {
087          return $this->arguments;
088      }
089   
090      public function needsEnvironment()
091      {
092          return $this->options['needs_environment'];
093      }
094   
095      public function needsContext()
096      {
097          return $this->options['needs_context'];
098      }
099   
100      public function getSafe(Node $functionArgs)
101      {
102          if (null !== $this->options['is_safe']) {
103              return $this->options['is_safe'];
104          }
105   
106          if (null !== $this->options['is_safe_callback']) {
107              return $this->options['is_safe_callback']($functionArgs);
108          }
109   
110          return [];
111      }
112   
113      public function isVariadic()
114      {
115          return $this->options['is_variadic'];
116      }
117   
118      public function isDeprecated()
119      {
120          return (bool) $this->options['deprecated'];
121      }
122   
123      public function getDeprecatedVersion()
124      {
125          return $this->options['deprecated'];
126      }
127   
128      public function getAlternative()
129      {
130          return $this->options['alternative'];
131      }
132  }
133   
134  // For Twig 1.x compatibility
135  class_alias('Twig\TwigFunction', 'Twig_SimpleFunction', false);
136   
137  class_alias('Twig\TwigFunction', 'Twig_Function');
138   
139  // Ensure that the aliased name is loaded to keep BC for classes implementing the typehint with the old aliased name.
140  class_exists('Twig\Node\Node');
141