Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ExpressionParser.php

function ExpressionParser::parseAssignmentExpression

File

vendor/twig/twig/src/ExpressionParser.php, line 700

Class

ExpressionParser
Parses expressions.

Namespace

Twig

Code

public function parseAssignmentExpression() {
    $stream = $this->parser
        ->getStream();
    $targets = [];
    while (true) {
        $token = $this->parser
            ->getCurrentToken();
        if ($stream->test(Token::OPERATOR_TYPE) && preg_match(Lexer::REGEX_NAME, $token->getValue())) {
            // in this context, string operators are variable names
            $this->parser
                ->getStream()
                ->next();
        }
        else {
            $stream->expect(Token::NAME_TYPE, null, 'Only variables can be assigned to');
        }
        $targets[] = new AssignContextVariable($token->getValue(), $token->getLine());
        if (!$stream->nextIf(Token::PUNCTUATION_TYPE, ',')) {
            break;
        }
    }
    return new Nodes($targets);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal