From 7704ba918fbbacfd40a87725b2e01fde58b186d0 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Wed, 21 Dec 2022 18:52:18 -0500 Subject: Drop php74 (#120) * PHPStan Level 6 * Drop PHP 7.4 support * Add PHPStan badge to readme * Code style cleanup --- src/NXP/MathExecutor.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/NXP/MathExecutor.php') diff --git a/src/NXP/MathExecutor.php b/src/NXP/MathExecutor.php index e991586..c857e99 100644 --- a/src/NXP/MathExecutor.php +++ b/src/NXP/MathExecutor.php @@ -140,9 +140,8 @@ class MathExecutor * Get a specific var * * @throws UnknownVariableException if VarNotFoundHandler is not set - * @return int|float */ - public function getVar(string $variable) + public function getVar(string $variable) : mixed { if (! \array_key_exists($variable, $this->variables)) { if ($this->onVarNotFound) { @@ -160,7 +159,7 @@ class MathExecutor * * @throws MathExecutorException if the value is invalid based on the default or custom validator */ - public function setVar(string $variable, $value) : self + public function setVar(string $variable, mixed $value) : self { if ($this->onVarValidation) { \call_user_func($this->onVarValidation, $variable, $value); @@ -273,8 +272,6 @@ class MathExecutor /** * Remove a specific operator - * - * @return array of operator class names */ public function removeOperator(string $operator) : self { @@ -380,7 +377,7 @@ class MathExecutor 180, false ], - '^' => [static fn ($a, $b) => \pow($a, $b), 220, true], + '^' => [static fn ($a, $b) => $a ** $b, 220, true], '%' => [static fn ($a, $b) => $a % $b, 180, false], '&&' => [static fn ($a, $b) => $a && $b, 100, false], '||' => [static fn ($a, $b) => $a || $b, 90, false], @@ -521,7 +518,7 @@ class MathExecutor * Default variable validation, ensures that the value is a scalar or array. * @throws MathExecutorException if the value is not a scalar */ - protected function defaultVarValidation(string $variable, $value) : void + protected function defaultVarValidation(string $variable, mixed $value) : void { if (! \is_scalar($value) && ! \is_array($value) && null !== $value) { $type = \gettype($value); -- cgit v1.2.3