src/Twig/TokenParser/ComponentTokenParser.php
/**
   * Tokenizes the component stream.
   *
   * @return array
   *   Array containing data and only flag.
   */
Tokenizes the component stream.
@return array
Array containing data and only flag.
Tokenizes the component stream . @return array Array containing data and only flag .
protected function parseArguments(): array {
    $data = NULL;
    $only = FALSE;
    $stream = $this->parser->getStream();
    if ($stream->test(Token::BLOCK_END_TYPE)) {
      $stream->expect(Token::BLOCK_END_TYPE);
      return [$data, $only];
    }
    if ($stream->test(Token::NAME_TYPE, 'only')) {
      $only = TRUE;
      $stream->next();
      $stream->expect(Token::BLOCK_END_TYPE);
      return [$data, $only];
    }
    $data = $this->parser->getExpressionParser()->parseExpression();
    if ($stream->test(Token::NAME_TYPE, 'only')) {
      $only = TRUE;
      $stream->next();
    }
    $stream->expect(Token::BLOCK_END_TYPE);
    return [$data, $only];
  }
protected function parseArguments ( ) : array { $ data = NULL ; $ only = FALSE ; $ stream = $ this -> parser -> getStream ( ) ; if ( $ stream -> test ( Token :: BLOCK_END_TYPE ) ) { $ stream -> expect ( Token :: BLOCK_END_TYPE ) ; return [ $ data , $ only ] ; } if ( $ stream -> test ( Token :: NAME_TYPE , 'only' ) ) { $ only = TRUE ; $ stream -> next ( ) ; $ stream -> expect ( Token :: BLOCK_END_TYPE ) ; return [ $ data , $ only ] ; } $ data = $ this -> parser -> getExpressionParser ( ) -> parseExpression ( ) ; if ( $ stream -> test ( Token :: NAME_TYPE , 'only' ) ) { $ only = TRUE ; $ stream -> next ( ) ; } $ stream -> expect ( Token :: BLOCK_END_TYPE ) ; return [ $ data , $ only ] ; }
Tokenizes the component stream.
Tokenizes the component stream .
/** @var \Twig\TokenStream $stream */ // BLOCK_END_TYPE = delimiter for blocks. // NAME_TYPE = name expression. /** @var \Twig\Node\Expression\ArrayExpression $data */