@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | $stack[] = new Token(Token::LITERAL, $value, $variable); |
| 116 | 116 | } elseif (Token::FUNCTION === $token->getType()) { |
| 117 | - if (! array_key_exists($token->getValue(), $this->functions)) { |
|
| 117 | + if (!array_key_exists($token->getValue(), $this->functions)) { |
|
| 118 | 118 | throw new UnknownFunctionException(sprintf( |
| 119 | 119 | 'Unknown function [%s]', |
| 120 | 120 | $token->getValue() |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $stack[] = $this->functions[$token->getValue()] |
| 124 | 124 | ->execute($stack, $token->getParamCount()); |
| 125 | 125 | } elseif (Token::OPERATOR === $token->getType()) { |
| 126 | - if (! array_key_exists($token->getValue(), $this->operators)) { |
|
| 126 | + if (!array_key_exists($token->getValue(), $this->operators)) { |
|
| 127 | 127 | throw new UnknownOperatorException(sprintf( |
| 128 | 128 | 'Unknown operator [%s]', |
| 129 | 129 | $token->getValue() |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | $result = array_pop($stack); |
| 136 | - if ($result === null || ! empty($stack)) { |
|
| 136 | + if ($result === null || !empty($stack)) { |
|
| 137 | 137 | throw new IncorrectExpressionException('Expression stack is not empty'); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -324,7 +324,7 @@ |
||
| 324 | 324 | */ |
| 325 | 325 | public function buildReversePolishNotation(): array |
| 326 | 326 | { |
| 327 | - $tokens = []; |
|
| 327 | + $tokens = []; |
|
| 328 | 328 | /** @var SplStack<Token> $stack */ |
| 329 | 329 | $stack = new SplStack(); |
| 330 | 330 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function getVariable(string $name) |
| 176 | 176 | { |
| 177 | - if (! array_key_exists($name, $this->variables)) { |
|
| 177 | + if (!array_key_exists($name, $this->variables)) { |
|
| 178 | 178 | if ($this->variableNotFoundHandler !== null) { |
| 179 | 179 | return call_user_func($this->variableNotFoundHandler, $name); |
| 180 | 180 | } |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | 'uNeg' => [static fn($a) => 0 - $a, 200, false], |
| 374 | 374 | '*' => [static fn($a, $b) => $a * $b, 180, false], |
| 375 | 375 | '/' => [ |
| 376 | - static function ($a, $b) { |
|
| 376 | + static function($a, $b) { |
|
| 377 | 377 | if ($b == 0) { |
| 378 | 378 | throw new DivisionByZeroException(); |
| 379 | 379 | } |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | protected function defaultFunctions(): array |
| 404 | 404 | { |
| 405 | 405 | return [ |
| 406 | - 'abs' => static function ($arg) { |
|
| 406 | + 'abs' => static function($arg) { |
|
| 407 | 407 | if ((int) $arg == $arg) { |
| 408 | 408 | return abs(intval($arg)); |
| 409 | 409 | } |
| 410 | 410 | return abs(floatval($arg)); |
| 411 | 411 | }, |
| 412 | 412 | 'array' => static fn(...$args) => $args, |
| 413 | - 'avg' => static function ($arg1, ...$args) { |
|
| 413 | + 'avg' => static function($arg1, ...$args) { |
|
| 414 | 414 | if (is_array($arg1)) { |
| 415 | 415 | if (count($arg1) === 0) { |
| 416 | 416 | throw new InvalidArgumentException('Array must contains at least one element'); |
@@ -422,13 +422,13 @@ discard block |
||
| 422 | 422 | $args = [$arg1, ...$args]; |
| 423 | 423 | return array_sum($args) / count($args); |
| 424 | 424 | }, |
| 425 | - 'ceil' => static function ($arg) { |
|
| 425 | + 'ceil' => static function($arg) { |
|
| 426 | 426 | if ((int) $arg == $arg) { |
| 427 | 427 | return ceil(intval($arg)); |
| 428 | 428 | } |
| 429 | 429 | return ceil(floatval($arg)); |
| 430 | 430 | }, |
| 431 | - 'floor' => static function ($arg) { |
|
| 431 | + 'floor' => static function($arg) { |
|
| 432 | 432 | if ((int) $arg == $arg) { |
| 433 | 433 | return floor(intval($arg)); |
| 434 | 434 | } |
@@ -444,14 +444,14 @@ discard block |
||
| 444 | 444 | 'sqrt' => static fn($arg) => sqrt(floatval($arg)), |
| 445 | 445 | 'hypot' => static fn($arg1, $arg2) => hypot(floatval($arg1), floatval($arg2)), |
| 446 | 446 | 'intdiv' => static fn($arg1, $arg2) => intdiv(intval($arg1), intval($arg2)), |
| 447 | - 'max' => static function ($arg1, ...$args) { |
|
| 447 | + 'max' => static function($arg1, ...$args) { |
|
| 448 | 448 | if (is_array($arg1) && count($arg1) === 0) { |
| 449 | 449 | throw new InvalidArgumentException('Array must contains at least one element'); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | return max(is_array($arg1) ? $arg1 : [$arg1, ...$args]); |
| 453 | 453 | }, |
| 454 | - 'min' => static function ($arg1, ...$args) { |
|
| 454 | + 'min' => static function($arg1, ...$args) { |
|
| 455 | 455 | if (is_array($arg1) && count($arg1) === 0) { |
| 456 | 456 | throw new InvalidArgumentException('Array must contains at least one element'); |
| 457 | 457 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | return min(is_array($arg1) ? $arg1 : [$arg1, ...$args]); |
| 460 | 460 | }, |
| 461 | 461 | 'pow' => static fn($arg1, $arg2) => $arg1 ** $arg2, |
| 462 | - 'round' => static function ($arg, int $precision = 0) { |
|
| 462 | + 'round' => static function($arg, int $precision = 0) { |
|
| 463 | 463 | if ((int) $arg == $arg) { |
| 464 | 464 | return round(intval($arg), intval($precision)); |
| 465 | 465 | } |