aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes/Calculator.php
diff options
context:
space:
mode:
authorFatih Kızmaz <barka_21@hotmail.com>2022-05-13 15:55:52 +0300
committerGitHub <noreply@github.com>2022-05-13 15:55:52 +0300
commite21d59c9def9f25bc6a7c3fbd41e2e126d68b1df (patch)
tree379ebf22c76d48aa5897bb9db487c60cae542533 /src/NXP/Classes/Calculator.php
parentda506a7ce05c6141e3c32f72c351eace38577f89 (diff)
Support unlimited args for min, max default funcs. (#106)
* Support unlimited args for min, max default funcs. Default functions max and min were requiring 2 arguments strictly. Now they supoort unlimited args, same as php's min, max funcs. * Improved functions: support unlimited parameters (see min, max funcs), optional parameters (see round func), parameters with types (see round func, throws IncorrectFunctionParameterException on unmatched type, union types and intersection types not supported because of min php level! there is a todo for this, to support them later @see CustomFunction@execute) Also added unittests for improvements. * Run php-cs-fixer fix
Diffstat (limited to 'src/NXP/Classes/Calculator.php')
-rw-r--r--src/NXP/Classes/Calculator.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/NXP/Classes/Calculator.php b/src/NXP/Classes/Calculator.php
index 10adc24..6b63503 100644
--- a/src/NXP/Classes/Calculator.php
+++ b/src/NXP/Classes/Calculator.php
@@ -74,7 +74,7 @@ class Calculator
if (! \array_key_exists($token->value, $this->functions)) {
throw new UnknownFunctionException($token->value);
}
- $stack[] = $this->functions[$token->value]->execute($stack);
+ $stack[] = $this->functions[$token->value]->execute($stack, $token->paramCount);
} elseif (Token::Operator === $token->type) {
if (! \array_key_exists($token->value, $this->operators)) {
throw new UnknownOperatorException($token->value);