diff options
author | Javier Marín <javier@marinros.com> | 2020-09-15 03:47:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-15 03:47:26 +0300 |
commit | f8faf3fa8d21ebd6e6f8c73f022eb64e407dc6e1 (patch) | |
tree | 752ca6f1602526ce36e38b289f2bb54630c4a0e3 /src | |
parent | 44d72cc252974ac36cc138591aac785022760a50 (diff) |
Improved support for null variables (#72)V2.1.2
* Added handler to define not found variables
Added support for string variables
Fixed strings and ints comparison error
* Check if variables have scalar types (int, float, string and bool)
Better $onVarNotFound logic
* Better support for null variables
* Better support for null variables
* Better support for null variables
Diffstat (limited to 'src')
-rw-r--r-- | src/NXP/Classes/Calculator.php | 4 | ||||
-rw-r--r-- | src/NXP/MathExecutor.php | 2 |
2 files changed, 2 insertions, 4 deletions
diff --git a/src/NXP/Classes/Calculator.php b/src/NXP/Classes/Calculator.php index 49142df..4785a8f 100644 --- a/src/NXP/Classes/Calculator.php +++ b/src/NXP/Classes/Calculator.php @@ -64,9 +64,7 @@ class Calculator $value = $variables[$variable]; } elseif ($onVarNotFound) { $value = call_user_func($onVarNotFound, $variable); - } - - if (!isset($value)) { + } else { throw new UnknownVariableException($variable); } diff --git a/src/NXP/MathExecutor.php b/src/NXP/MathExecutor.php index 434246a..f45335c 100644 --- a/src/NXP/MathExecutor.php +++ b/src/NXP/MathExecutor.php @@ -416,7 +416,7 @@ class MathExecutor */ public function getVar(string $variable) { - if (!isset($this->variables[$variable])) { + if (!array_key_exists($variable, $this->variables)) { throw new UnknownVariableException("Variable ({$variable}) not set"); } return $this->variables[$variable]; |