aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/MathExecutor.php
diff options
context:
space:
mode:
authorBruce Wells <brucekwells@gmail.com>2022-12-22 02:52:18 +0300
committerGitHub <noreply@github.com>2022-12-22 02:52:18 +0300
commit7704ba918fbbacfd40a87725b2e01fde58b186d0 (patch)
treebd9889db81eaca0e8dc8be46303ea75d9cbf58ac /src/NXP/MathExecutor.php
parentc59f4cd15317754d2b50bd4bff2243012e815790 (diff)
Drop php74 (#120)
* PHPStan Level 6 * Drop PHP 7.4 support * Add PHPStan badge to readme * Code style cleanup
Diffstat (limited to 'src/NXP/MathExecutor.php')
-rw-r--r--src/NXP/MathExecutor.php11
1 files changed, 4 insertions, 7 deletions
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<Operator> 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);