From e21d59c9def9f25bc6a7c3fbd41e2e126d68b1df Mon Sep 17 00:00:00 2001 From: Fatih Kızmaz Date: Fri, 13 May 2022 15:55:52 +0300 Subject: 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 --- src/NXP/Classes/Calculator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/NXP/Classes/Calculator.php') 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); -- cgit v1.2.3