[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/twig/twig/src/Node/ -> ForLoopNode.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;
  13  
  14  use Twig\Compiler;
  15  
  16  /**
  17   * Internal node used by the for node.
  18   *
  19   * @author Fabien Potencier <fabien@symfony.com>
  20   */
  21  class ForLoopNode extends Node
  22  {
  23      public function __construct($lineno, $tag = null)
  24      {
  25          parent::__construct([], ['with_loop' => false, 'ifexpr' => false, 'else' => false], $lineno, $tag);
  26      }
  27  
  28      public function compile(Compiler $compiler)
  29      {
  30          if ($this->getAttribute('else')) {
  31              $compiler->write("\$context['_iterated'] = true;\n");
  32          }
  33  
  34          if ($this->getAttribute('with_loop')) {
  35              $compiler
  36                  ->write("++\$context['loop']['index0'];\n")
  37                  ->write("++\$context['loop']['index'];\n")
  38                  ->write("\$context['loop']['first'] = false;\n")
  39              ;
  40  
  41              if (!$this->getAttribute('ifexpr')) {
  42                  $compiler
  43                      ->write("if (isset(\$context['loop']['length'])) {\n")
  44                      ->indent()
  45                      ->write("--\$context['loop']['revindex0'];\n")
  46                      ->write("--\$context['loop']['revindex'];\n")
  47                      ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n")
  48                      ->outdent()
  49                      ->write("}\n")
  50                  ;
  51              }
  52          }
  53      }
  54  }
  55  
  56  class_alias('Twig\Node\ForLoopNode', 'Twig_Node_ForLoop');


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