You are here

public function Twig_ExpressionParser::parseAssignmentExpression in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/ExpressionParser.php \Twig_ExpressionParser::parseAssignmentExpression()

File

vendor/twig/twig/lib/Twig/ExpressionParser.php, line 537

Class

Twig_ExpressionParser
Parses expressions.

Code

public function parseAssignmentExpression() {
  $targets = array();
  while (true) {
    $token = $this->parser
      ->getStream()
      ->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
    if (in_array($token
      ->getValue(), array(
      'true',
      'false',
      'none',
    ))) {
      throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s".', $token
        ->getValue()), $token
        ->getLine(), $this->parser
        ->getFilename());
    }
    $targets[] = new Twig_Node_Expression_AssignName($token
      ->getValue(), $token
      ->getLine());
    if (!$this->parser
      ->getStream()
      ->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
      break;
    }
  }
  return new Twig_Node($targets);
}