mirror of
https://github.com/flextype/flextype.git
synced 2025-08-06 13:16:45 +02:00
feat(expressions): types fixes
This commit is contained in:
@@ -26,9 +26,9 @@ class DateExpression implements ExpressionFunctionProviderInterface
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('date', static fn (string $format, ?int $timestamp = null): string => '\date($format, $timestamp)', static fn (array $arguments, string $format, ?int $timestamp = null): string => \date($format, $timestamp)),
|
||||
new ExpressionFunction('time', static fn (): string => '\time()', static fn (array $arguments): string => \time()),
|
||||
new ExpressionFunction('strtotime', static fn (string $datetime, ?int $baseTimestamp = null): int|false => '\strtotime($datetime, $baseTimestamp)', static fn (array $arguments, string $datetime, ?int $baseTimestamp = null): int|false => \strtotime($datetime, $baseTimestamp))
|
||||
new ExpressionFunction('date', static fn (string $format, ?int $timestamp = null) => '\date($format, $timestamp)', static fn (array $arguments, string $format, ?int $timestamp = null): string => \date($format, $timestamp)),
|
||||
new ExpressionFunction('time', static fn () => '\time()', static fn (array $arguments): int => \time()),
|
||||
new ExpressionFunction('strtotime', static fn (string $datetime, ?int $baseTimestamp = null) => '\strtotime($datetime, $baseTimestamp)', static fn (array $arguments, string $datetime, ?int $baseTimestamp = null): int|false => \strtotime($datetime, $baseTimestamp))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -20,18 +20,19 @@ use Symfony\Component\ExpressionLanguage\ExpressionFunction;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
|
||||
|
||||
use function Flextype\registry;
|
||||
use const PHP_ROUND_HALF_UP;
|
||||
|
||||
class MathExpression implements ExpressionFunctionProviderInterface
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new ExpressionFunction('abs', static fn (int|float $num): mixed => '\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 = 1): mixed => '\round($num, $precision, $mode)', static fn (array $arguments, int|float $num, int $precision = 0, int $mode = 1): mixed => \round($num, $precision, $mode)),
|
||||
new ExpressionFunction('ceil', static fn (int|float $num): mixed => '\ceil($num)', static fn (array $arguments, int|float $num): mixed => \ceil($num)),
|
||||
new ExpressionFunction('floor', static fn (int|float $num): mixed => '\floor($num)', static fn (array $arguments, int|float $num): mixed => \floor($num)),
|
||||
new ExpressionFunction('min', static fn (mixed ...$values): mixed => '\min($values)', static fn (array $arguments, mixed ...$values): mixed => \min($values)),
|
||||
new ExpressionFunction('max', static fn (mixed ...$values): mixed => '\max($values)', static fn (array $arguments, mixed ...$values): mixed => \max($values)),
|
||||
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 = 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)),
|
||||
new ExpressionFunction('max', static fn (mixed ...$values) => '\max($values)', static fn (array $arguments, mixed ...$values): mixed => \max($values)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user