You are here

public function Twig_ExpressionParser::parseAssignmentExpression in Translation template extractor 6.3

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

File

vendor/Twig/ExpressionParser.php, line 512

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);
}