[ExpressionLanguage][Node][BinaryNode] Process division by zero
This commit is contained in:
parent
a054d88830
commit
02ab72ab30
@ -147,8 +147,16 @@ class BinaryNode extends Node
|
||||
case '*':
|
||||
return $left * $right;
|
||||
case '/':
|
||||
if (0 == $right) {
|
||||
throw new \DivisionByZeroError('Division by zero');
|
||||
}
|
||||
|
||||
return $left / $right;
|
||||
case '%':
|
||||
if (0 == $right) {
|
||||
throw new \DivisionByZeroError('Modulo by zero');
|
||||
}
|
||||
|
||||
return $left % $right;
|
||||
case 'matches':
|
||||
return preg_match($right, $left);
|
||||
|
@ -17,7 +17,8 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.5.9|>=7.0.8",
|
||||
"symfony/cache": "~3.1|~4.0"
|
||||
"symfony/cache": "~3.1|~4.0",
|
||||
"symfony/polyfill-php70": "~1.6"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" },
|
||||
|
Reference in New Issue
Block a user