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

MacroTokenParser.php

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


01  <?php
02   
03  /*
04   * This file is part of Twig.
05   *
06   * (c) Fabien Potencier
07   *
08   * For the full copyright and license information, please view the LICENSE
09   * file that was distributed with this source code.
10   */
11   
12  namespace Twig\TokenParser;
13   
14  use Twig\Error\SyntaxError;
15  use Twig\Node\BodyNode;
16  use Twig\Node\MacroNode;
17  use Twig\Node\Node;
18  use Twig\Token;
19   
20  /**
21   * Defines a macro.
22   *
23   *   {% macro input(name, value, type, size) %}
24   *      <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}" size="{{ size|default(20) }}" />
25   *   {% endmacro %}
26   */
27  final class MacroTokenParser extends AbstractTokenParser
28  {
29      public function parse(Token $token)
30      {
31          $lineno = $token->getLine();
32          $stream = $this->parser->getStream();
33          $name = $stream->expect(/* Token::NAME_TYPE */ 5)->getValue();
34   
35          $arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
36   
37          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
38          $this->parser->pushLocalScope();
39          $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
40          if ($token = $stream->nextIf(/* Token::NAME_TYPE */ 5)) {
41              $value = $token->getValue();
42   
43              if ($value != $name) {
44                  throw new SyntaxError(sprintf('Expected endmacro for macro "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext());
45              }
46          }
47          $this->parser->popLocalScope();
48          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
49   
50          $this->parser->setMacro($name, new MacroNode($name, new BodyNode([$body]), $arguments, $lineno, $this->getTag()));
51   
52          return new Node();
53      }
54   
55      public function decideBlockEnd(Token $token)
56      {
57          return $token->test('endmacro');
58      }
59   
60      public function getTag()
61      {
62          return 'macro';
63      }
64  }
65   
66  class_alias('Twig\TokenParser\MacroTokenParser', 'Twig_TokenParser_Macro');
67