diff options
Diffstat (limited to 'src/NXP/Classes/Calculator.php')
-rw-r--r-- | src/NXP/Classes/Calculator.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/NXP/Classes/Calculator.php b/src/NXP/Classes/Calculator.php index 2bb5b4d..10adc24 100644 --- a/src/NXP/Classes/Calculator.php +++ b/src/NXP/Classes/Calculator.php @@ -20,10 +20,18 @@ use NXP\Exception\UnknownVariableException; */ class Calculator { + /** @var array<string, CustomFunction> */ private array $functions = []; + /** @var array<Operator> */ private array $operators = []; + /** + * @todo PHP8: Use constructor property promotion -> public function __construct(private array $functions, private array $operators) + * + * @param array<string, CustomFunction> $functions + * @param array<Operator> $operators + */ public function __construct(array $functions, array $operators) { $this->functions = $functions; @@ -32,10 +40,13 @@ class Calculator /** * Calculate array of tokens in reverse polish notation - * @param Token[] $tokens + * + * @param Token[] $tokens * @param array<string, float|string> $variables - * @throws IncorrectExpressionException + * * @throws UnknownVariableException + * @throws IncorrectExpressionException + * @return int|float|string|null */ public function calculate(array $tokens, array $variables, ?callable $onVarNotFound = null) { |