Skip to content

Commit e84f4cb

Browse files
committed
fix: the error 'an unexpected error occured "" [] false' for an empty formula
1 parent 2d806cc commit e84f4cb

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

expression.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public function e($expr)
171171
*/
172172
public function evaluate($expr)
173173
{
174+
if (empty($expr)) {
175+
return false;
176+
}
174177
$this->_functions = array_merge($this->_functions, $this->functions);
175178
$this->last_error = null;
176179
$expr = preg_replace("/\r|\n/", '', trim($expr));

tests/Expression.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testEmptyFormula()
2727
$expr = new Expression();
2828
$expr->suppress_errors = true;
2929
$this->assertEquals($expr->evaluate(''), false);
30+
$this->assertEmpty($expr->last_error);
3031
}
3132

3233
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)