function ExpressionParser::parseExpression
11 calls to ExpressionParser::parseExpression()
- ExpressionParser::getPrimary in vendor/
twig/ twig/ src/ ExpressionParser.php - ExpressionParser::parseArguments in vendor/
twig/ twig/ src/ ExpressionParser.php - Parses arguments.
- ExpressionParser::parseArrow in vendor/
twig/ twig/ src/ ExpressionParser.php - ExpressionParser::parseConditionalExpression in vendor/
twig/ twig/ src/ ExpressionParser.php - ExpressionParser::parseMappingExpression in vendor/
twig/ twig/ src/ ExpressionParser.php
File
-
vendor/
twig/ twig/ src/ ExpressionParser.php, line 93
Class
- ExpressionParser
- Parses expressions.
Namespace
TwigCode
public function parseExpression($precedence = 0) {
if (func_num_args() > 1) {
trigger_deprecation('twig/twig', '3.15', 'Passing a second argument ($allowArrow) to "%s()" is deprecated.', __METHOD__);
}
if ($arrow = $this->parseArrow()) {
return $arrow;
}
$expr = $this->getPrimary();
$token = $this->parser
->getCurrentToken();
while ($this->isBinary($token) && $this->binaryOperators[$token->getValue()]['precedence'] >= $precedence) {
$op = $this->binaryOperators[$token->getValue()];
$this->parser
->getStream()
->next();
if ('is not' === $token->getValue()) {
$expr = $this->parseNotTestExpression($expr);
}
elseif ('is' === $token->getValue()) {
$expr = $this->parseTestExpression($expr);
}
elseif (isset($op['callable'])) {
$expr = $op['callable']($this->parser, $expr);
}
else {
$previous = $this->setDeprecationCheck(true);
try {
$expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
} finally {
$this->setDeprecationCheck($previous);
}
$class = $op['class'];
$expr = new $class($expr, $expr1, $token->getLine());
}
$expr->setAttribute('operator', 'binary_' . $token->getValue());
$this->triggerPrecedenceDeprecations($expr);
$token = $this->parser
->getCurrentToken();
}
if (0 === $precedence) {
return $this->parseConditionalExpression($expr);
}
return $expr;
}