You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #4775 Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity (fabpot)
This PR was merged into the 3.x branch.
Discussion
----------
Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity
Closes#4767Closes#4774
Commits
-------
e5eb95d Add getOperatorTokens() to ExpressionParserInterface to separate operator token registration from parser identity
Copy file name to clipboardExpand all lines: src/ExpressionParser/ExpressionParsers.php
+33-5Lines changed: 33 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -54,10 +54,9 @@ public function add(array $parsers): static
54
54
// throw new \InvalidArgumentException(\sprintf('Precedence for "%s" must be between 0 and 512, got %d.', $parser->getName(), $parser->getPrecedence()));
if (method_exists($parser, 'getOperatorTokens')) {
148
+
return$parser->getOperatorTokens();
149
+
}
150
+
151
+
trigger_deprecation('twig/twig', '3.24', 'Not implementing the "getOperatorTokens()" method in "%s" is deprecated. This method will be part of the "%s" interface in 4.0.', $parser::class, ExpressionParserInterface::class);
@@ -796,6 +799,36 @@ public static function getBindingPowerTests(): iterable
796
799
yield'= stronger than logical' => ['{% do a = false or true %}{{ a }}', '{% do a = (false or true) %}{{ a }}', eval('$a = false || true; return $a;')];
797
800
yield'= stronger than ternary' => ['{% do c = 4 ? 0 : -1 %}{{ c }}', '{% do c = (4 ? 0 : -1) %}{{ c }}', eval('return 4 ? 0 : -1;')];
0 commit comments