Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

IfTokenParser.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 2.47 KiB


 01  <?php
 02   
 03  /*
 04   * This file is part of Twig.
 05   *
 06   * (c) Fabien Potencier
 07   * (c) Armin Ronacher
 08   *
 09   * For the full copyright and license information, please view the LICENSE
 10   * file that was distributed with this source code.
 11   */
 12   
 13  namespace Twig\TokenParser;
 14   
 15  use Twig\Error\SyntaxError;
 16  use Twig\Node\IfNode;
 17  use Twig\Node\Node;
 18  use Twig\Token;
 19   
 20  /**
 21   * Tests a condition.
 22   *
 23   *   {% if users %}
 24   *    <ul>
 25   *      {% for user in users %}
 26   *        <li>{{ user.username|e }}</li>
 27   *      {% endfor %}
 28   *    </ul>
 29   *   {% endif %}
 30   */
 31  final class IfTokenParser extends AbstractTokenParser
 32  {
 33      public function parse(Token $token)
 34      {
 35          $lineno = $token->getLine();
 36          $expr = $this->parser->getExpressionParser()->parseExpression();
 37          $stream = $this->parser->getStream();
 38          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
 39          $body = $this->parser->subparse([$this, 'decideIfFork']);
 40          $tests = [$expr, $body];
 41          $else = null;
 42   
 43          $end = false;
 44          while (!$end) {
 45              switch ($stream->next()->getValue()) {
 46                  case 'else':
 47                      $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
 48                      $else = $this->parser->subparse([$this, 'decideIfEnd']);
 49                      break;
 50   
 51                  case 'elseif':
 52                      $expr = $this->parser->getExpressionParser()->parseExpression();
 53                      $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
 54                      $body = $this->parser->subparse([$this, 'decideIfFork']);
 55                      $tests[] = $expr;
 56                      $tests[] = $body;
 57                      break;
 58   
 59                  case 'endif':
 60                      $end = true;
 61                      break;
 62   
 63                  default:
 64                      throw new SyntaxError(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d).', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext());
 65              }
 66          }
 67   
 68          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
 69   
 70          return new IfNode(new Node($tests), $else, $lineno, $this->getTag());
 71      }
 72   
 73      public function decideIfFork(Token $token)
 74      {
 75          return $token->test(['elseif', 'else', 'endif']);
 76      }
 77   
 78      public function decideIfEnd(Token $token)
 79      {
 80          return $token->test(['endif']);
 81      }
 82   
 83      public function getTag()
 84      {
 85          return 'if';
 86      }
 87  }
 88   
 89  class_alias('Twig\TokenParser\IfTokenParser', 'Twig_TokenParser_If');
 90