Add support for detecting if an expression had explicit parentheses

This commit is contained in:
Fabien Potencier
2024-09-30 11:52:45 +02:00
parent 4e08e3ef5f
commit d133ab7e70
3 changed files with 19 additions and 9 deletions
+2 -7
View File
@@ -169,15 +169,10 @@ class ExpressionParser
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
} elseif ($token->test(Token::PUNCTUATION_TYPE, '(')) {
$this->parser->getStream()->next();
$expr = $this->parseExpression();
$expr = $this->parseExpression()->setExplicitParentheses();
$this->parser->getStream()->expect(Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
$expr = $this->parsePostfixExpression($expr);
if ($expr instanceof NegUnary) {
$expr->wrapInParentheses();
}
return $expr;
return $this->parsePostfixExpression($expr);
}
return $this->parsePrimaryExpression();