Skip to content

Commit

Permalink
Add some type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 30, 2024
1 parent a0d52fd commit 9f8c52d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/ExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ public function parseExpression($precedence = 0, $allowArrow = false)

if (
($expr instanceof AddBinary || $expr instanceof SubBinary)
&&
(
($expr->getNode('left') instanceof ConcatBinary && !$expr->getNode('left')->hasExplicitParentheses())
||
($expr->getNode('right') instanceof ConcatBinary && !$expr->getNode('right')->hasExplicitParentheses())
)
) {
trigger_deprecation('twig/twig', '3.15', \sprintf('As "+" / "-" will have a higher precedence than "~" in Twig 4.0, please add parentheses to keep the current behavior in "%s" at line %d.', $this->parser->getStream()->getSourceContext()->getName(), $token->getLine()));
/** @var AbstractExpression $left */
$left = $expr->getNode('left');
/** @var AbstractExpression $right */
$right = $expr->getNode('right');
if (
($left instanceof ConcatBinary && !$left->hasExplicitParentheses())
||
($right instanceof ConcatBinary && !$right->hasExplicitParentheses())
) {
trigger_deprecation('twig/twig', '3.15', \sprintf('As "+" / "-" will have a higher precedence than "~" in Twig 4.0, please add parentheses to keep the current behavior in "%s" at line %d.', $this->parser->getStream()->getSourceContext()->getName(), $token->getLine()));
}
}

if (0 === $precedence) {
Expand Down

0 comments on commit 9f8c52d

Please sign in to comment.