function ExpressionParser::parseAssignmentExpression
File
-
vendor/
twig/ twig/ src/ ExpressionParser.php, line 700
Class
- ExpressionParser
- Parses expressions.
Namespace
TwigCode
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);
}