[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/vendor/twig/twig/src/TokenParser/ -> WithTokenParser.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\TokenParser;
  13  
  14  use Twig\Node\WithNode;
  15  use Twig\Token;
  16  
  17  /**
  18   * Creates a nested scope.
  19   *
  20   * @author Fabien Potencier <fabien@symfony.com>
  21   *
  22   * @final
  23   */
  24  class WithTokenParser extends AbstractTokenParser
  25  {
  26      public function parse(Token $token)
  27      {
  28          $stream = $this->parser->getStream();
  29  
  30          $variables = null;
  31          $only = false;
  32          if (!$stream->test(Token::BLOCK_END_TYPE)) {
  33              $variables = $this->parser->getExpressionParser()->parseExpression();
  34              $only = $stream->nextIf(Token::NAME_TYPE, 'only');
  35          }
  36  
  37          $stream->expect(Token::BLOCK_END_TYPE);
  38  
  39          $body = $this->parser->subparse([$this, 'decideWithEnd'], true);
  40  
  41          $stream->expect(Token::BLOCK_END_TYPE);
  42  
  43          return new WithNode($body, $variables, $only, $token->getLine(), $this->getTag());
  44      }
  45  
  46      public function decideWithEnd(Token $token)
  47      {
  48          return $token->test('endwith');
  49      }
  50  
  51      public function getTag()
  52      {
  53          return 'with';
  54      }
  55  }
  56  
  57  class_alias('Twig\TokenParser\WithTokenParser', 'Twig_TokenParser_With');


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1