diff --git a/phpstan.neon b/phpstan.neon index 5f7869e1..4cea516c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,3 +9,4 @@ parameters: - '#Undefined variable: \$this.*#' - '/Variable \$api_errors might not be defined./' - '/Variable \$registry might not be defined./' + - 'Parameter #3 $mode of function round expects 1|2|3|4, int given.' diff --git a/src/flextype/core/Parsers/Expressions/MathExpression.php b/src/flextype/core/Parsers/Expressions/MathExpression.php index 35e33fe2..5a17b3c4 100644 --- a/src/flextype/core/Parsers/Expressions/MathExpression.php +++ b/src/flextype/core/Parsers/Expressions/MathExpression.php @@ -25,24 +25,13 @@ use const PHP_ROUND_HALF_UP; use const PHP_ROUND_HALF_DOWN; use const PHP_ROUND_HALF_ODD; -/** - * @phpstan-param self::ROUND_* $mode - */ class MathExpression implements ExpressionFunctionProviderInterface { - public const ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN; - public const ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN; - public const ROUND_HALF_ODD = PHP_ROUND_HALF_ODD; - public const ROUND_HALF_UP = PHP_ROUND_HALF_UP; - - /** - * @phpstan-param self::ROUND_* $mode - */ public function getFunctions() { return [ new ExpressionFunction('abs', static fn (int|float $num) => '\abs($num)', static fn (array $arguments, int|float $num): mixed => \abs($num)), - new ExpressionFunction('round', static fn (int|float $num, int $precision = 0, int $mode = self::PHP_ROUND_HALF_UP): mixed => '\round($num, $precision, $mode)', static fn (array $arguments, int|float $num, int $precision = 0, int $mode = self::PHP_ROUND_HALF_UP): mixed => \round($num, $precision, $mode)), + new ExpressionFunction('round', static fn (int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): mixed => '\round($num, $precision, $mode)', static fn (array $arguments, int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): mixed => \round($num, $precision, $mode)), new ExpressionFunction('ceil', static fn (int|float $num) => '\ceil($num)', static fn (array $arguments, int|float $num): mixed => \ceil($num)), new ExpressionFunction('floor', static fn (int|float $num) => '\floor($num)', static fn (array $arguments, int|float $num): mixed => \floor($num)), new ExpressionFunction('min', static fn (mixed ...$values) => '\min($values)', static fn (array $arguments, mixed ...$values): mixed => \min($values)),