aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/NXP/Classes')
-rw-r--r--src/NXP/Classes/Calculator.php6
-rw-r--r--src/NXP/Classes/Lexer.php1
-rw-r--r--src/NXP/Classes/Token/AbstractOperator.php1
-rw-r--r--src/NXP/Classes/TokenFactory.php8
4 files changed, 13 insertions, 3 deletions
diff --git a/src/NXP/Classes/Calculator.php b/src/NXP/Classes/Calculator.php
index 980a52b..7d82ecd 100644
--- a/src/NXP/Classes/Calculator.php
+++ b/src/NXP/Classes/Calculator.php
@@ -26,9 +26,9 @@ class Calculator
{
/**
* Calculate array of tokens in reverse polish notation
- * @param array $tokens Array of tokens
- * @param array $variables Array of variables
- * @return number Result
+ * @param array $tokens
+ * @param array $variables
+ * @return number Result
* @throws \NXP\Exception\IncorrectExpressionException
* @throws \NXP\Exception\UnknownVariableException
*/
diff --git a/src/NXP/Classes/Lexer.php b/src/NXP/Classes/Lexer.php
index cd12d21..a7fe697 100644
--- a/src/NXP/Classes/Lexer.php
+++ b/src/NXP/Classes/Lexer.php
@@ -155,6 +155,7 @@ class Lexer
private function isNegativeZero($x)
{
$floatVal = floatval($x);
+
return $floatVal === 0.0 && $floatVal ** -1 === -INF;
}
}
diff --git a/src/NXP/Classes/Token/AbstractOperator.php b/src/NXP/Classes/Token/AbstractOperator.php
index 8b23ad8..67e8031 100644
--- a/src/NXP/Classes/Token/AbstractOperator.php
+++ b/src/NXP/Classes/Token/AbstractOperator.php
@@ -35,6 +35,7 @@ abstract class AbstractOperator implements InterfaceToken, InterfaceOperator
public function setDivisionByZeroException($exception = true)
{
$this->divideByZeroReporting = $exception;
+
return $this;
}
diff --git a/src/NXP/Classes/TokenFactory.php b/src/NXP/Classes/TokenFactory.php
index 5aa634a..70d1ba9 100644
--- a/src/NXP/Classes/TokenFactory.php
+++ b/src/NXP/Classes/TokenFactory.php
@@ -54,6 +54,7 @@ class TokenFactory
* @param string $name
* @param callable $function
* @param int $places
+ * @return TokenFactory
* @throws \ReflectionException
*/
public function addFunction($name, callable $function, $places = null)
@@ -63,6 +64,8 @@ class TokenFactory
$places = $reflector->getNumberOfParameters();
}
$this->functions[$name] = [$places, $function];
+
+ return $this;
}
/**
@@ -79,6 +82,7 @@ class TokenFactory
/**
* Add operator
* @param string $operatorClass
+ * @return TokenFactory
* @throws UnknownOperatorException
* @throws \ReflectionException
*/
@@ -91,6 +95,8 @@ class TokenFactory
}
$this->operators[$operatorClass::getRegex()] = $operatorClass;
+
+ return $this;
}
/**
@@ -113,6 +119,7 @@ class TokenFactory
public function setDivisionByZeroException($exception = true)
{
$this->divideByZeroReporting = $exception;
+
return $this;
}
@@ -147,6 +154,7 @@ class TokenFactory
TokenComma::getRegex()
);
$s .= $operatorsRegex . '/i';
+
return $s;
}