Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 02ab72a

Browse files
tigr1991nicolas-grekas
authored andcommitted
[ExpressionLanguage][Node][BinaryNode] Process division by zero
1 parent a054d88 commit 02ab72a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,16 @@ public function evaluate($functions, $values)
147147
case '*':
148148
return $left * $right;
149149
case '/':
150+
if (0 == $right) {
151+
throw new \DivisionByZeroError('Division by zero');
152+
}
153+
150154
return $left / $right;
151155
case '%':
156+
if (0 == $right) {
157+
throw new \DivisionByZeroError('Modulo by zero');
158+
}
159+
152160
return $left % $right;
153161
case 'matches':
154162
return preg_match($right, $left);

src/Symfony/Component/ExpressionLanguage/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": "^5.5.9|>=7.0.8",
20-
"symfony/cache": "~3.1|~4.0"
20+
"symfony/cache": "~3.1|~4.0",
21+
"symfony/polyfill-php70": "~1.6"
2122
},
2223
"autoload": {
2324
"psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" },

0 commit comments

Comments
 (0)