[ Index ]

PHP Cross Reference of phpBB-3.3.12-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 class WithTokenParser extends AbstractTokenParser
  23  {
  24      public function parse(Token $token)
  25      {
  26          $stream = $this->parser->getStream();
  27  
  28          $variables = null;
  29          $only = false;
  30          if (!$stream->test(/* Token::BLOCK_END_TYPE */ 3)) {
  31              $variables = $this->parser->getExpressionParser()->parseExpression();
  32              $only = (bool) $stream->nextIf(/* Token::NAME_TYPE */ 5, 'only');
  33          }
  34  
  35          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
  36  
  37          $body = $this->parser->subparse([$this, 'decideWithEnd'], true);
  38  
  39          $stream->expect(/* Token::BLOCK_END_TYPE */ 3);
  40  
  41          return new WithNode($body, $variables, $only, $token->getLine(), $this->getTag());
  42      }
  43  
  44      public function decideWithEnd(Token $token)
  45      {
  46          return $token->test('endwith');
  47      }
  48  
  49      public function getTag()
  50      {
  51          return 'with';
  52      }
  53  }
  54  
  55  class_alias('Twig\TokenParser\WithTokenParser', 'Twig_TokenParser_With');


Generated: Sun Jun 23 12:25:44 2024 Cross-referenced by PHPXref 0.7.1