[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 '*':
|
case '*':
|
||||||
return $left * $right;
|
return $left * $right;
|
||||||
case '/':
|
case '/':
|
||||||
|
if (0 == $right) {
|
||||||
|
throw new \DivisionByZeroError('Division by zero');
|
||||||
|
}
|
||||||
|
|
||||||
return $left / $right;
|
return $left / $right;
|
||||||
case '%':
|
case '%':
|
||||||
|
if (0 == $right) {
|
||||||
|
throw new \DivisionByZeroError('Modulo by zero');
|
||||||
|
}
|
||||||
|
|
||||||
return $left % $right;
|
return $left % $right;
|
||||||
case 'matches':
|
case 'matches':
|
||||||
return preg_match($right, $left);
|
return preg_match($right, $left);
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5.9|>=7.0.8",
|
"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": {
|
"autoload": {
|
||||||
"psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" },
|
"psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" },
|
||||||
|
Reference in New Issue
Block a user