diff --git a/generator/config/expressions.php b/generator/config/expressions.php index 916fa9d5d..5e1283e6f 100644 --- a/generator/config/expressions.php +++ b/generator/config/expressions.php @@ -21,8 +21,9 @@ function typeFieldPath(string $resolvesTo): array return [ 'null' => ['scalar' => true, 'types' => ['null']], - 'number' => ['scalar' => true, 'types' => ['int']], - 'decimal' => ['scalar' => true, 'types' => ['float']], + 'int' => ['scalar' => true, 'types' => ['int', BSON\Int64::class]], + 'number' => ['scalar' => true, 'types' => ['int', BSON\Int64::class]], + 'decimal' => ['scalar' => true, 'types' => ['float', BSON\Decimal128::class]], 'string' => ['scalar' => true, 'types' => ['string']], 'boolean' => ['scalar' => true, 'types' => ['bool']], diff --git a/generator/config/stages.yaml b/generator/config/stages.yaml index 320fa83d1..eb9fe7250 100644 --- a/generator/config/stages.yaml +++ b/generator/config/stages.yaml @@ -6,6 +6,7 @@ - name: sort type: stage args: + # @todo should generate be a map, not a list - name: sortSpecification type: number # should be an enum PHPLIB-1269 isVariadic: true @@ -13,7 +14,7 @@ type: stage args: - name: limit - type: resolvesToInt + type: int - name: group type: stage encode: object diff --git a/src/Builder/Stage.php b/src/Builder/Stage.php index de64201aa..c1471211f 100644 --- a/src/Builder/Stage.php +++ b/src/Builder/Stage.php @@ -8,7 +8,6 @@ use MongoDB\BSON\Int64; use MongoDB\Builder\Expression\ExpressionInterface; -use MongoDB\Builder\Expression\ResolvesToInt; use MongoDB\Builder\Stage\GroupStage; use MongoDB\Builder\Stage\LimitStage; use MongoDB\Builder\Stage\MatchStage; @@ -27,9 +26,9 @@ public static function group(mixed $_id, mixed ...$fields): GroupStage } /** - * @param Int64|ResolvesToInt|int $limit + * @param Int64|int $limit */ - public static function limit(Int64|ResolvesToInt|int $limit): LimitStage + public static function limit(Int64|int $limit): LimitStage { return new LimitStage($limit); } @@ -51,9 +50,9 @@ public static function project(mixed ...$specifications): ProjectStage } /** - * @param int ...$sortSpecification + * @param Int64|int ...$sortSpecification */ - public static function sort(int ...$sortSpecification): SortStage + public static function sort(Int64|int ...$sortSpecification): SortStage { return new SortStage(...$sortSpecification); } diff --git a/src/Builder/Stage/LimitStage.php b/src/Builder/Stage/LimitStage.php index e8ed074f8..78d1dd4c7 100644 --- a/src/Builder/Stage/LimitStage.php +++ b/src/Builder/Stage/LimitStage.php @@ -7,19 +7,18 @@ namespace MongoDB\Builder\Stage; use MongoDB\BSON\Int64; -use MongoDB\Builder\Expression\ResolvesToInt; class LimitStage implements StageInterface { public const NAME = '$limit'; public const ENCODE = 'single'; - public Int64|ResolvesToInt|int $limit; + public Int64|int $limit; /** - * @param Int64|ResolvesToInt|int $limit + * @param Int64|int $limit */ - public function __construct(Int64|ResolvesToInt|int $limit) + public function __construct(Int64|int $limit) { $this->limit = $limit; } diff --git a/src/Builder/Stage/SortStage.php b/src/Builder/Stage/SortStage.php index 254b50657..b06177df4 100644 --- a/src/Builder/Stage/SortStage.php +++ b/src/Builder/Stage/SortStage.php @@ -6,18 +6,20 @@ namespace MongoDB\Builder\Stage; +use MongoDB\BSON\Int64; + class SortStage implements StageInterface { public const NAME = '$sort'; public const ENCODE = 'single'; - /** @param list ...$sortSpecification */ + /** @param list ...$sortSpecification */ public array $sortSpecification; /** - * @param int $sortSpecification + * @param Int64|int $sortSpecification */ - public function __construct(int ...$sortSpecification) + public function __construct(Int64|int ...$sortSpecification) { if (\count($sortSpecification) < 1) { throw new \InvalidArgumentException(\sprintf('Expected at least %d values, got %d.', 1, \count($sortSpecification)));