mirror of
https://github.com/flextype/flextype.git
synced 2025-08-05 04:37:43 +02:00
feat(expressions): types fixes
This commit is contained in:
@@ -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.'
|
||||
|
@@ -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)),
|
||||
|
Reference in New Issue
Block a user