From 452bf50bc7764327340e801d9955db5676b11f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 27 Nov 2024 17:57:17 +0100 Subject: [PATCH] Remove specific encoder for Group and DollarGroup, use property name map --- generator/README.md | 24 ++++-- generator/config/query/geoIntersects.yaml | 3 +- generator/config/query/geoWithin.yaml | 3 +- generator/config/query/near.yaml | 7 +- generator/config/query/nearSphere.yaml | 7 +- generator/config/query/text.yaml | 10 +-- generator/config/schema.json | 13 ++-- generator/config/stage/group.yaml | 3 +- .../src/Definition/ArgumentDefinition.php | 1 + .../src/Definition/OperatorDefinition.php | 2 - generator/src/OperatorClassGenerator.php | 76 +++++++++++-------- generator/src/OperatorFactoryGenerator.php | 11 +-- phpcs.xml.dist | 3 + psalm-baseline.xml | 13 +++- .../Accumulator/AccumulatorAccumulator.php | 10 +++ .../Accumulator/AddToSetAccumulator.php | 1 + src/Builder/Accumulator/AvgAccumulator.php | 1 + src/Builder/Accumulator/BottomAccumulator.php | 1 + .../Accumulator/BottomNAccumulator.php | 1 + .../Accumulator/CovariancePopAccumulator.php | 1 + .../Accumulator/CovarianceSampAccumulator.php | 1 + .../Accumulator/DerivativeAccumulator.php | 1 + .../Accumulator/ExpMovingAvgAccumulator.php | 1 + src/Builder/Accumulator/FirstAccumulator.php | 1 + src/Builder/Accumulator/FirstNAccumulator.php | 1 + .../Accumulator/IntegralAccumulator.php | 1 + src/Builder/Accumulator/LastAccumulator.php | 1 + src/Builder/Accumulator/LastNAccumulator.php | 1 + .../Accumulator/LinearFillAccumulator.php | 1 + src/Builder/Accumulator/LocfAccumulator.php | 1 + src/Builder/Accumulator/MaxAccumulator.php | 1 + src/Builder/Accumulator/MaxNAccumulator.php | 1 + src/Builder/Accumulator/MedianAccumulator.php | 1 + .../Accumulator/MergeObjectsAccumulator.php | 1 + src/Builder/Accumulator/MinAccumulator.php | 1 + src/Builder/Accumulator/MinNAccumulator.php | 1 + .../Accumulator/PercentileAccumulator.php | 1 + src/Builder/Accumulator/PushAccumulator.php | 1 + src/Builder/Accumulator/ShiftAccumulator.php | 1 + .../Accumulator/StdDevPopAccumulator.php | 1 + .../Accumulator/StdDevSampAccumulator.php | 1 + src/Builder/Accumulator/SumAccumulator.php | 1 + src/Builder/Accumulator/TopAccumulator.php | 1 + src/Builder/Accumulator/TopNAccumulator.php | 1 + src/Builder/Encoder/OperatorEncoder.php | 74 +++++------------- src/Builder/Expression/AbsOperator.php | 1 + src/Builder/Expression/AcosOperator.php | 1 + src/Builder/Expression/AcoshOperator.php | 1 + src/Builder/Expression/AddOperator.php | 1 + .../Expression/AllElementsTrueOperator.php | 1 + src/Builder/Expression/AndOperator.php | 1 + .../Expression/AnyElementTrueOperator.php | 1 + .../Expression/ArrayElemAtOperator.php | 1 + .../Expression/ArrayToObjectOperator.php | 1 + src/Builder/Expression/AsinOperator.php | 1 + src/Builder/Expression/AsinhOperator.php | 1 + src/Builder/Expression/Atan2Operator.php | 1 + src/Builder/Expression/AtanOperator.php | 1 + src/Builder/Expression/AtanhOperator.php | 1 + src/Builder/Expression/AvgOperator.php | 1 + src/Builder/Expression/BinarySizeOperator.php | 1 + src/Builder/Expression/BitAndOperator.php | 1 + src/Builder/Expression/BitNotOperator.php | 1 + src/Builder/Expression/BitOrOperator.php | 1 + src/Builder/Expression/BitXorOperator.php | 1 + src/Builder/Expression/BsonSizeOperator.php | 1 + src/Builder/Expression/CaseOperator.php | 1 + src/Builder/Expression/CeilOperator.php | 1 + src/Builder/Expression/CmpOperator.php | 1 + .../Expression/ConcatArraysOperator.php | 1 + src/Builder/Expression/ConcatOperator.php | 1 + src/Builder/Expression/CondOperator.php | 1 + src/Builder/Expression/ConvertOperator.php | 1 + src/Builder/Expression/CosOperator.php | 1 + src/Builder/Expression/CoshOperator.php | 1 + src/Builder/Expression/DateAddOperator.php | 1 + src/Builder/Expression/DateDiffOperator.php | 8 ++ .../Expression/DateFromPartsOperator.php | 14 ++++ .../Expression/DateFromStringOperator.php | 8 ++ .../Expression/DateSubtractOperator.php | 1 + .../Expression/DateToPartsOperator.php | 1 + .../Expression/DateToStringOperator.php | 1 + src/Builder/Expression/DateTruncOperator.php | 8 ++ src/Builder/Expression/DayOfMonthOperator.php | 1 + src/Builder/Expression/DayOfWeekOperator.php | 1 + src/Builder/Expression/DayOfYearOperator.php | 1 + .../Expression/DegreesToRadiansOperator.php | 1 + src/Builder/Expression/DivideOperator.php | 1 + src/Builder/Expression/EqOperator.php | 1 + src/Builder/Expression/ExpOperator.php | 1 + src/Builder/Expression/FilterOperator.php | 1 + src/Builder/Expression/FirstNOperator.php | 1 + src/Builder/Expression/FirstOperator.php | 1 + src/Builder/Expression/FloorOperator.php | 1 + src/Builder/Expression/FunctionOperator.php | 1 + src/Builder/Expression/GetFieldOperator.php | 1 + src/Builder/Expression/GtOperator.php | 1 + src/Builder/Expression/GteOperator.php | 1 + src/Builder/Expression/HourOperator.php | 1 + src/Builder/Expression/IfNullOperator.php | 1 + src/Builder/Expression/InOperator.php | 1 + .../Expression/IndexOfArrayOperator.php | 1 + .../Expression/IndexOfBytesOperator.php | 1 + src/Builder/Expression/IndexOfCPOperator.php | 1 + src/Builder/Expression/IsArrayOperator.php | 1 + src/Builder/Expression/IsNumberOperator.php | 1 + .../Expression/IsoDayOfWeekOperator.php | 1 + src/Builder/Expression/IsoWeekOperator.php | 1 + .../Expression/IsoWeekYearOperator.php | 1 + src/Builder/Expression/LastNOperator.php | 1 + src/Builder/Expression/LastOperator.php | 1 + src/Builder/Expression/LetOperator.php | 1 + src/Builder/Expression/LiteralOperator.php | 1 + src/Builder/Expression/LnOperator.php | 1 + src/Builder/Expression/Log10Operator.php | 1 + src/Builder/Expression/LogOperator.php | 1 + src/Builder/Expression/LtOperator.php | 1 + src/Builder/Expression/LteOperator.php | 1 + src/Builder/Expression/LtrimOperator.php | 1 + src/Builder/Expression/MapOperator.php | 1 + src/Builder/Expression/MaxNOperator.php | 1 + src/Builder/Expression/MaxOperator.php | 1 + src/Builder/Expression/MedianOperator.php | 1 + .../Expression/MergeObjectsOperator.php | 1 + src/Builder/Expression/MetaOperator.php | 1 + .../Expression/MillisecondOperator.php | 1 + src/Builder/Expression/MinNOperator.php | 1 + src/Builder/Expression/MinOperator.php | 1 + src/Builder/Expression/MinuteOperator.php | 1 + src/Builder/Expression/ModOperator.php | 1 + src/Builder/Expression/MonthOperator.php | 1 + src/Builder/Expression/MultiplyOperator.php | 1 + src/Builder/Expression/NeOperator.php | 1 + src/Builder/Expression/NotOperator.php | 1 + .../Expression/ObjectToArrayOperator.php | 1 + src/Builder/Expression/OrOperator.php | 1 + src/Builder/Expression/PercentileOperator.php | 1 + src/Builder/Expression/PowOperator.php | 1 + .../Expression/RadiansToDegreesOperator.php | 1 + src/Builder/Expression/RangeOperator.php | 1 + src/Builder/Expression/ReduceOperator.php | 1 + .../Expression/RegexFindAllOperator.php | 1 + src/Builder/Expression/RegexFindOperator.php | 1 + src/Builder/Expression/RegexMatchOperator.php | 1 + src/Builder/Expression/ReplaceAllOperator.php | 1 + src/Builder/Expression/ReplaceOneOperator.php | 1 + .../Expression/ReverseArrayOperator.php | 1 + src/Builder/Expression/RoundOperator.php | 1 + src/Builder/Expression/RtrimOperator.php | 1 + src/Builder/Expression/SecondOperator.php | 1 + .../Expression/SetDifferenceOperator.php | 1 + src/Builder/Expression/SetEqualsOperator.php | 1 + src/Builder/Expression/SetFieldOperator.php | 1 + .../Expression/SetIntersectionOperator.php | 1 + .../Expression/SetIsSubsetOperator.php | 1 + src/Builder/Expression/SetUnionOperator.php | 1 + src/Builder/Expression/SinOperator.php | 1 + src/Builder/Expression/SinhOperator.php | 1 + src/Builder/Expression/SizeOperator.php | 1 + src/Builder/Expression/SliceOperator.php | 1 + src/Builder/Expression/SortArrayOperator.php | 1 + src/Builder/Expression/SplitOperator.php | 1 + src/Builder/Expression/SqrtOperator.php | 1 + src/Builder/Expression/StdDevPopOperator.php | 1 + src/Builder/Expression/StdDevSampOperator.php | 1 + .../Expression/StrLenBytesOperator.php | 1 + src/Builder/Expression/StrLenCPOperator.php | 1 + src/Builder/Expression/StrcasecmpOperator.php | 1 + .../Expression/SubstrBytesOperator.php | 1 + src/Builder/Expression/SubstrCPOperator.php | 1 + src/Builder/Expression/SubstrOperator.php | 1 + src/Builder/Expression/SubtractOperator.php | 1 + src/Builder/Expression/SumOperator.php | 1 + src/Builder/Expression/SwitchOperator.php | 1 + src/Builder/Expression/TanOperator.php | 1 + src/Builder/Expression/TanhOperator.php | 1 + src/Builder/Expression/ToBoolOperator.php | 1 + src/Builder/Expression/ToDateOperator.php | 1 + src/Builder/Expression/ToDecimalOperator.php | 1 + src/Builder/Expression/ToDoubleOperator.php | 1 + .../Expression/ToHashedIndexKeyOperator.php | 1 + src/Builder/Expression/ToIntOperator.php | 1 + src/Builder/Expression/ToLongOperator.php | 1 + src/Builder/Expression/ToLowerOperator.php | 1 + src/Builder/Expression/ToObjectIdOperator.php | 1 + src/Builder/Expression/ToStringOperator.php | 1 + src/Builder/Expression/ToUpperOperator.php | 1 + src/Builder/Expression/TrimOperator.php | 1 + src/Builder/Expression/TruncOperator.php | 1 + .../Expression/TsIncrementOperator.php | 1 + src/Builder/Expression/TsSecondOperator.php | 1 + src/Builder/Expression/TypeOperator.php | 1 + src/Builder/Expression/UnsetFieldOperator.php | 1 + src/Builder/Expression/WeekOperator.php | 1 + src/Builder/Expression/YearOperator.php | 1 + src/Builder/Expression/ZipOperator.php | 1 + src/Builder/Query/AllOperator.php | 1 + src/Builder/Query/AndOperator.php | 1 + src/Builder/Query/BitsAllClearOperator.php | 1 + src/Builder/Query/BitsAllSetOperator.php | 1 + src/Builder/Query/BitsAnyClearOperator.php | 1 + src/Builder/Query/BitsAnySetOperator.php | 1 + src/Builder/Query/BoxOperator.php | 1 + src/Builder/Query/CenterOperator.php | 1 + src/Builder/Query/CenterSphereOperator.php | 1 + src/Builder/Query/CommentOperator.php | 1 + src/Builder/Query/ElemMatchOperator.php | 1 + src/Builder/Query/EqOperator.php | 1 + src/Builder/Query/ExistsOperator.php | 1 + src/Builder/Query/ExprOperator.php | 1 + src/Builder/Query/GeoIntersectsOperator.php | 3 +- src/Builder/Query/GeoWithinOperator.php | 3 +- src/Builder/Query/GeometryOperator.php | 1 + src/Builder/Query/GtOperator.php | 1 + src/Builder/Query/GteOperator.php | 1 + src/Builder/Query/InOperator.php | 1 + src/Builder/Query/JsonSchemaOperator.php | 1 + src/Builder/Query/LtOperator.php | 1 + src/Builder/Query/LteOperator.php | 1 + src/Builder/Query/MaxDistanceOperator.php | 1 + src/Builder/Query/MinDistanceOperator.php | 1 + src/Builder/Query/ModOperator.php | 1 + src/Builder/Query/NeOperator.php | 1 + src/Builder/Query/NearOperator.php | 3 +- src/Builder/Query/NearSphereOperator.php | 3 +- src/Builder/Query/NinOperator.php | 1 + src/Builder/Query/NorOperator.php | 1 + src/Builder/Query/NotOperator.php | 1 + src/Builder/Query/OrOperator.php | 1 + src/Builder/Query/PolygonOperator.php | 1 + src/Builder/Query/RegexOperator.php | 1 + src/Builder/Query/SampleRateOperator.php | 1 + src/Builder/Query/SizeOperator.php | 1 + src/Builder/Query/TextOperator.php | 9 ++- src/Builder/Query/TypeOperator.php | 1 + src/Builder/Query/WhereOperator.php | 1 + src/Builder/Stage/AddFieldsStage.php | 1 + src/Builder/Stage/BucketAutoStage.php | 7 ++ src/Builder/Stage/BucketStage.php | 7 ++ src/Builder/Stage/ChangeStreamStage.php | 10 +++ src/Builder/Stage/CollStatsStage.php | 7 ++ src/Builder/Stage/CountStage.php | 1 + src/Builder/Stage/CurrentOpStage.php | 8 ++ src/Builder/Stage/DensifyStage.php | 1 + src/Builder/Stage/DocumentsStage.php | 1 + src/Builder/Stage/FacetStage.php | 1 + src/Builder/Stage/FillStage.php | 7 ++ src/Builder/Stage/GeoNearStage.php | 12 +++ src/Builder/Stage/GraphLookupStage.php | 11 +++ src/Builder/Stage/GroupStage.php | 3 +- src/Builder/Stage/LimitStage.php | 1 + src/Builder/Stage/ListLocalSessionsStage.php | 1 + src/Builder/Stage/ListSampledQueriesStage.php | 1 + src/Builder/Stage/ListSearchIndexesStage.php | 1 + src/Builder/Stage/ListSessionsStage.php | 1 + src/Builder/Stage/LookupStage.php | 9 +++ src/Builder/Stage/MatchStage.php | 1 + src/Builder/Stage/MergeStage.php | 8 ++ src/Builder/Stage/OutStage.php | 1 + src/Builder/Stage/ProjectStage.php | 1 + src/Builder/Stage/RedactStage.php | 1 + src/Builder/Stage/ReplaceRootStage.php | 1 + src/Builder/Stage/ReplaceWithStage.php | 1 + src/Builder/Stage/SampleStage.php | 1 + src/Builder/Stage/SearchMetaStage.php | 1 + src/Builder/Stage/SearchStage.php | 1 + src/Builder/Stage/SetStage.php | 1 + src/Builder/Stage/SetWindowFieldsStage.php | 1 + src/Builder/Stage/SkipStage.php | 1 + src/Builder/Stage/SortByCountStage.php | 1 + src/Builder/Stage/SortStage.php | 1 + src/Builder/Stage/UnionWithStage.php | 1 + src/Builder/Stage/UnsetStage.php | 1 + src/Builder/Stage/UnwindStage.php | 6 ++ src/Builder/Type/Encode.php | 10 --- src/Builder/Type/OperatorInterface.php | 5 +- 276 files changed, 525 insertions(+), 141 deletions(-) diff --git a/generator/README.md b/generator/README.md index 5b6449543..a14037604 100644 --- a/generator/README.md +++ b/generator/README.md @@ -10,17 +10,30 @@ Updating the generated code can be done only by modifying the code generator, or To run the generator, you need to have PHP 8.1+ installed and Composer. 1. Move to the `generator` directory: `cd generator` -1. Install dependencies: `composer install` -1. Run the generator: `./generate` +2. Install dependencies: `composer install` +3. Run the generator: `./generate` ## Configuration The `generator/config/*.yaml` files contains the list of operators and stages that are supported by the library. +### Arguments + +| Field | Type | Description | +| `name` | `string` | The name of the argument. It can start with `$`. | +| `type` | list of `string` | The list of accepted types | +| `description` | `string` | The description of the argument from MongoDB's documentation. | +| `optional` | `boolean` | Whether the argument is optional or not. | +| `valueMin` | `number` | The minimum value for a numeric argument. | +| `valueMax` | `number` | The maximum value for a numeric argument. | +| `variadic` | `string` | If sent, the argument is variadic. Defines the format `array` for a list or `object` for a map | +| `variadicMin` | `integer` | The minimum number of arguments for a variadic parameter. | +| `default` | `scalar` or `array` | The default value for the argument. | +| `noName` | `bool` | Default `false`. If `true`, the value must be an object and the properties of the value object are merged into the parent operator. `$group` stage uses it for the fields. | + ### Test pipelines -Each operator can contain a `tests` section with a list if pipelines. To represent specific BSON objects, -it is necessary to use Yaml tags: +Each operator can contain a `tests` section with a list if pipelines. To represent specific BSON objects, it is necessary to use Yaml tags: | BSON Type | Example | |-------------|--------------------------------------------------------| @@ -30,5 +43,4 @@ it is necessary to use Yaml tags: | UTCDateTime | `!bson_utcdatetime 0` | | Binary | `!bson_binary 'IA=='` | -To add new test cases to operators, you can get inspiration from the official MongoDB documentation and use -the `generator/js2yaml.html` web page to manually convert a pipeline array from JS to Yaml. +To add new test cases to operators, you can get inspiration from the official MongoDB documentation and use the `generator/js2yaml.html` web page to manually convert a pipeline array from JS to Yaml. diff --git a/generator/config/query/geoIntersects.yaml b/generator/config/query/geoIntersects.yaml index ca1eda02f..6a675e3b5 100644 --- a/generator/config/query/geoIntersects.yaml +++ b/generator/config/query/geoIntersects.yaml @@ -3,12 +3,13 @@ name: $geoIntersects link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/' type: - fieldQuery -encode: single +encode: object description: | Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects. arguments: - name: geometry + noName: true type: - geometry tests: diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index 3a87e4b72..ae19744fd 100644 --- a/generator/config/query/geoWithin.yaml +++ b/generator/config/query/geoWithin.yaml @@ -3,12 +3,13 @@ name: $geoWithin link: 'https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/' type: - fieldQuery -encode: single +encode: object description: | Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin. arguments: - name: geometry + noName: true type: - geometry tests: diff --git a/generator/config/query/near.yaml b/generator/config/query/near.yaml index f2c791630..010911f54 100644 --- a/generator/config/query/near.yaml +++ b/generator/config/query/near.yaml @@ -3,23 +3,24 @@ name: $near link: 'https://www.mongodb.com/docs/manual/reference/operator/query/near/' type: - fieldQuery -encode: dollar_object +encode: object description: | Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near. arguments: - name: geometry + noName: true type: - geometry - - name: maxDistance + name: $maxDistance type: - number optional: true description: | Distance in meters. Limits the results to those documents that are at most the specified distance from the center point. - - name: minDistance + name: $minDistance type: - number optional: true diff --git a/generator/config/query/nearSphere.yaml b/generator/config/query/nearSphere.yaml index 3411127ad..1a9e4f205 100644 --- a/generator/config/query/nearSphere.yaml +++ b/generator/config/query/nearSphere.yaml @@ -3,23 +3,24 @@ name: $nearSphere link: 'https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/' type: - fieldQuery -encode: dollar_object +encode: object description: | Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere. arguments: - name: geometry + noName: true type: - geometry - - name: maxDistance + name: $maxDistance type: - number optional: true description: | Distance in meters. - - name: minDistance + name: $minDistance type: - number optional: true diff --git a/generator/config/query/text.yaml b/generator/config/query/text.yaml index 5ec26aaec..574ee4508 100644 --- a/generator/config/query/text.yaml +++ b/generator/config/query/text.yaml @@ -3,18 +3,18 @@ name: $text link: 'https://www.mongodb.com/docs/manual/reference/operator/query/text/' type: - query -encode: dollar_object +encode: object description: | Performs text search. arguments: - - name: search + name: $search type: - string description: | A string of terms that MongoDB parses and uses to query the text index. MongoDB performs a logical OR search of the terms unless specified as a phrase. - - name: language + name: $language type: - string optional: true @@ -22,14 +22,14 @@ arguments: The language that determines the list of stop words for the search and the rules for the stemmer and tokenizer. If not specified, the search uses the default language of the index. If you specify a default_language value of none, then the text index parses through each word in the field, including stop words, and ignores suffix stemming. - - name: caseSensitive + name: $caseSensitive type: - bool optional: true description: | A boolean flag to enable or disable case sensitive search. Defaults to false; i.e. the search defers to the case insensitivity of the text index. - - name: diacriticSensitive + name: $diacriticSensitive type: - bool optional: true diff --git a/generator/config/schema.json b/generator/config/schema.json index a68564e8e..17d4b32a9 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -61,9 +61,7 @@ "array", "object", "flat_object", - "dollar_object", - "single", - "group" + "single" ] }, "description": { @@ -100,7 +98,7 @@ "properties": { "name": { "type": "string", - "pattern": "^(_?[a-z][a-zA-Z0-9]*|N)$" + "pattern": "^([_$]?[a-z][a-zA-Z0-9]*|N)$" }, "type": { "type": "array", @@ -150,7 +148,7 @@ "type": "number" }, "valueMax": { - "$comment": "The minimum value for a numeric argument.", + "$comment": "The maximum value for a numeric argument.", "type": "number" }, "variadic": { @@ -169,6 +167,11 @@ "default": { "$comment": "The default value for the argument.", "type": ["array", "boolean", "number", "string"] + }, + "noName": { + "$comment": "Skip the name in object encoding and merge the value object", + "type": "boolean", + "default": false } }, "required": [ diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index 3e93588e9..0f0cc6ca3 100644 --- a/generator/config/stage/group.yaml +++ b/generator/config/stage/group.yaml @@ -3,7 +3,7 @@ name: $group link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/' type: - stage -encode: group +encode: object description: | Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields. arguments: @@ -15,6 +15,7 @@ arguments: The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents. - name: field + noName: true type: - accumulator variadic: object diff --git a/generator/src/Definition/ArgumentDefinition.php b/generator/src/Definition/ArgumentDefinition.php index e45ea0da3..2a94a9cdc 100644 --- a/generator/src/Definition/ArgumentDefinition.php +++ b/generator/src/Definition/ArgumentDefinition.php @@ -25,6 +25,7 @@ public function __construct( string|null $variadic = null, int|null $variadicMin = null, public mixed $default = null, + public bool $noName = false, ) { assert($this->optional === false || $this->default === null, 'Optional arguments cannot have a default value'); if (is_array($type)) { diff --git a/generator/src/Definition/OperatorDefinition.php b/generator/src/Definition/OperatorDefinition.php index ce39fe4d7..eb9876239 100644 --- a/generator/src/Definition/OperatorDefinition.php +++ b/generator/src/Definition/OperatorDefinition.php @@ -40,8 +40,6 @@ public function __construct( 'array' => Encode::Array, 'object' => Encode::Object, 'flat_object' => Encode::FlatObject, - 'dollar_object' => Encode::DollarObject, - 'group' => Encode::Group, default => throw new UnexpectedValueException(sprintf('Unexpected "encode" value for operator "%s". Got "%s"', $name, $encode)), }; diff --git a/generator/src/OperatorClassGenerator.php b/generator/src/OperatorClassGenerator.php index 73fcf09bf..565631e3d 100644 --- a/generator/src/OperatorClassGenerator.php +++ b/generator/src/OperatorClassGenerator.php @@ -20,6 +20,7 @@ use function assert; use function interface_exists; +use function ltrim; use function rtrim; use function sprintf; use function var_export; @@ -61,27 +62,32 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition $namespace->addUse(Encode::class); $class->addConstant('ENCODE', new Literal('Encode::' . $operator->encode->name)); - $constuctor = $class->addMethod('__construct'); + $encodeNames = []; + $constructor = $class->addMethod('__construct'); foreach ($operator->arguments as $argument) { + // Remove the leading $ from the argument name + $argName = ltrim($argument->name, '$'); + $encodeNames[$argName] = $argument->noName ? null : $argument->name; + $type = $this->getAcceptedTypes($argument); foreach ($type->use as $use) { $namespace->addUse($use); } - $property = $class->addProperty($argument->name); + $property = $class->addProperty($argName); $property->setReadOnly(); - $constuctorParam = $constuctor->addParameter($argument->name); - $constuctorParam->setType($type->native); + $constructorParam = $constructor->addParameter($argName); + $constructorParam->setType($type->native); if ($argument->variadic) { - $constuctor->setVariadic(); - $constuctor->addComment('@param ' . $type->doc . ' ...$' . $argument->name . rtrim(' ' . $argument->description)); + $constructor->setVariadic(); + $constructor->addComment('@param ' . $type->doc . ' ...$' . $argName . rtrim(' ' . $argument->description)); if ($argument->variadicMin > 0) { $namespace->addUse(InvalidArgumentException::class); - $constuctor->addBody(<<name}) < {$argument->variadicMin}) { - throw new InvalidArgumentException(\sprintf('Expected at least %d values for \${$argument->name}, got %d.', {$argument->variadicMin}, \count(\${$argument->name}))); + $constructor->addBody(<<variadicMin}) { + throw new InvalidArgumentException(\sprintf('Expected at least %d values for \${$argName}, got %d.', {$argument->variadicMin}, \count(\${$argName}))); } PHP); @@ -89,45 +95,45 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition if ($argument->variadic === VariadicType::Array) { $property->setType('array'); - $property->addComment('@var list<' . $type->doc . '> $' . $argument->name . rtrim(' ' . $argument->description)); + $property->addComment('@var list<' . $type->doc . '> $' . $argName . rtrim(' ' . $argument->description)); // Warn that named arguments are not supported // @see https://psalm.dev/docs/running_psalm/issues/NamedArgumentNotAllowed/ - $constuctor->addComment('@no-named-arguments'); + $constructor->addComment('@no-named-arguments'); $namespace->addUseFunction('array_is_list'); $namespace->addUse(InvalidArgumentException::class); - $constuctor->addBody(<<name})) { - throw new InvalidArgumentException('Expected \${$argument->name} arguments to be a list (array), named arguments are not supported'); + $constructor->addBody(<<variadic === VariadicType::Object) { $namespace->addUse(stdClass::class); $property->setType(stdClass::class); - $property->addComment('@var stdClass<' . $type->doc . '> $' . $argument->name . rtrim(' ' . $argument->description)); + $property->addComment('@var stdClass<' . $type->doc . '> $' . $argName . rtrim(' ' . $argument->description)); $namespace->addUseFunction('is_string'); $namespace->addUse(InvalidArgumentException::class); - $constuctor->addBody(<<name} as \$key => \$value) { + $constructor->addBody(<< \$value) { if (! is_string(\$key)) { - throw new InvalidArgumentException('Expected \${$argument->name} arguments to be a map (object), named arguments (:) or array unpacking ...[\'\' => ] must be used'); + throw new InvalidArgumentException('Expected \${$argName} arguments to be a map (object), named arguments (:) or array unpacking ...[\'\' => ] must be used'); } } - \${$argument->name} = (object) \${$argument->name}; + \${$argName} = (object) \${$argName}; PHP); } } else { // Non-variadic arguments - $property->addComment('@var ' . $type->doc . ' $' . $argument->name . rtrim(' ' . $argument->description)); + $property->addComment('@var ' . $type->doc . ' $' . $argName . rtrim(' ' . $argument->description)); $property->setType($type->native); - $constuctor->addComment('@param ' . $type->doc . ' $' . $argument->name . rtrim(' ' . $argument->description)); + $constructor->addComment('@param ' . $type->doc . ' $' . $argName . rtrim(' ' . $argument->description)); if ($argument->optional) { // We use a special Optional::Undefined type to differentiate between null and undefined - $constuctorParam->setDefaultValue(new Literal('Optional::Undefined')); + $constructorParam->setDefaultValue(new Literal('Optional::Undefined')); } elseif ($argument->default !== null) { - $constuctorParam->setDefaultValue($argument->default); + $constructorParam->setDefaultValue($argument->default); } // List type must be validated with array_is_list() @@ -135,9 +141,9 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition $namespace->addUseFunction('is_array'); $namespace->addUseFunction('array_is_list'); $namespace->addUse(InvalidArgumentException::class); - $constuctor->addBody(<<name}) && ! array_is_list(\${$argument->name})) { - throw new InvalidArgumentException('Expected \${$argument->name} argument to be a list, got an associative array.'); + $constructor->addBody(<<query) { $namespace->addUseFunction('is_array'); $namespace->addUse(QueryObject::class); - $constuctor->addBody(<<name})) { - \${$argument->name} = QueryObject::create(\${$argument->name}); + $constructor->addBody(<<javascript) { $namespace->addUseFunction('is_string'); $namespace->addUse(Javascript::class); - $constuctor->addBody(<<name})) { - \${$argument->name} = new Javascript(\${$argument->name}); + $constructor->addBody(<<addBody('$this->' . $argument->name . ' = $' . $argument->name . ';'); + $constructor->addBody('$this->' . $argName . ' = $' . $argName . ';'); + } + + if ($encodeNames !== []) { + $class->addConstant('PROPERTIES', $encodeNames); } $class->addMethod('getOperator') diff --git a/generator/src/OperatorFactoryGenerator.php b/generator/src/OperatorFactoryGenerator.php index 0bc27620f..d2be1ebdd 100644 --- a/generator/src/OperatorFactoryGenerator.php +++ b/generator/src/OperatorFactoryGenerator.php @@ -60,12 +60,13 @@ private function addMethod(GeneratorDefinition $definition, OperatorDefinition $ $method->addComment('@see ' . $operator->link); $args = []; foreach ($operator->arguments as $argument) { + $argName = ltrim($argument->name, '$'); $type = $this->getAcceptedTypes($argument); foreach ($type->use as $use) { $namespace->addUse($use); } - $parameter = $method->addParameter($argument->name); + $parameter = $method->addParameter($argName); $parameter->setType($type->native); if ($argument->variadic) { if ($argument->variadic === VariadicType::Array) { @@ -75,8 +76,8 @@ private function addMethod(GeneratorDefinition $definition, OperatorDefinition $ } $method->setVariadic(); - $method->addComment('@param ' . $type->doc . ' ...$' . $argument->name . rtrim(' ' . $argument->description)); - $args[] = '...$' . $argument->name; + $method->addComment('@param ' . $type->doc . ' ...$' . $argName . rtrim(' ' . $argument->description)); + $args[] = '...$' . $argName; } else { if ($argument->optional) { $parameter->setDefaultValue(new Literal('Optional::Undefined')); @@ -84,8 +85,8 @@ private function addMethod(GeneratorDefinition $definition, OperatorDefinition $ $parameter->setDefaultValue($argument->default); } - $method->addComment('@param ' . $type->doc . ' $' . $argument->name . rtrim(' ' . $argument->description)); - $args[] = '$' . $argument->name; + $method->addComment('@param ' . $type->doc . ' $' . $argName . rtrim(' ' . $argument->description)); + $args[] = '$' . $argName; } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index de542ac64..0d349c0d9 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -160,4 +160,7 @@ /tests/SpecTests/*/Prose* + + src/Builder/Type/OperatorInterface.php + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4619f8206..4d703d593 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -61,14 +61,23 @@ + + + + + + + - - + + + + diff --git a/src/Builder/Accumulator/AccumulatorAccumulator.php b/src/Builder/Accumulator/AccumulatorAccumulator.php index a12b57c7c..911dff36e 100644 --- a/src/Builder/Accumulator/AccumulatorAccumulator.php +++ b/src/Builder/Accumulator/AccumulatorAccumulator.php @@ -32,6 +32,16 @@ class AccumulatorAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'init' => 'init', + 'accumulate' => 'accumulate', + 'accumulateArgs' => 'accumulateArgs', + 'merge' => 'merge', + 'lang' => 'lang', + 'initArgs' => 'initArgs', + 'finalize' => 'finalize', + ]; + /** @var Javascript|string $init Function used to initialize the state. The init function receives its arguments from the initArgs array expression. You can specify the function definition as either BSON type Code or String. */ public readonly Javascript|string $init; diff --git a/src/Builder/Accumulator/AddToSetAccumulator.php b/src/Builder/Accumulator/AddToSetAccumulator.php index 08bda8cea..345fbca6f 100644 --- a/src/Builder/Accumulator/AddToSetAccumulator.php +++ b/src/Builder/Accumulator/AddToSetAccumulator.php @@ -25,6 +25,7 @@ class AddToSetAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/AvgAccumulator.php b/src/Builder/Accumulator/AvgAccumulator.php index da0b7730a..832940275 100644 --- a/src/Builder/Accumulator/AvgAccumulator.php +++ b/src/Builder/Accumulator/AvgAccumulator.php @@ -25,6 +25,7 @@ class AvgAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Accumulator/BottomAccumulator.php b/src/Builder/Accumulator/BottomAccumulator.php index c8408bafc..da90cfe98 100644 --- a/src/Builder/Accumulator/BottomAccumulator.php +++ b/src/Builder/Accumulator/BottomAccumulator.php @@ -27,6 +27,7 @@ class BottomAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output']; /** @var Document|Serializable|array|stdClass $sortBy Specifies the order of results, with syntax similar to $sort. */ public readonly Document|Serializable|stdClass|array $sortBy; diff --git a/src/Builder/Accumulator/BottomNAccumulator.php b/src/Builder/Accumulator/BottomNAccumulator.php index 47e51852a..aee2d5f70 100644 --- a/src/Builder/Accumulator/BottomNAccumulator.php +++ b/src/Builder/Accumulator/BottomNAccumulator.php @@ -29,6 +29,7 @@ class BottomNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['n' => 'n', 'sortBy' => 'sortBy', 'output' => 'output']; /** @var ResolvesToInt|int $n Limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. */ public readonly ResolvesToInt|int $n; diff --git a/src/Builder/Accumulator/CovariancePopAccumulator.php b/src/Builder/Accumulator/CovariancePopAccumulator.php index 459ed5c6e..bb864a282 100644 --- a/src/Builder/Accumulator/CovariancePopAccumulator.php +++ b/src/Builder/Accumulator/CovariancePopAccumulator.php @@ -24,6 +24,7 @@ class CovariancePopAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression1 */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression1; diff --git a/src/Builder/Accumulator/CovarianceSampAccumulator.php b/src/Builder/Accumulator/CovarianceSampAccumulator.php index 1266b263e..96dc1a438 100644 --- a/src/Builder/Accumulator/CovarianceSampAccumulator.php +++ b/src/Builder/Accumulator/CovarianceSampAccumulator.php @@ -24,6 +24,7 @@ class CovarianceSampAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression1 */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression1; diff --git a/src/Builder/Accumulator/DerivativeAccumulator.php b/src/Builder/Accumulator/DerivativeAccumulator.php index 8010050d9..125fda6b9 100644 --- a/src/Builder/Accumulator/DerivativeAccumulator.php +++ b/src/Builder/Accumulator/DerivativeAccumulator.php @@ -29,6 +29,7 @@ class DerivativeAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'unit' => 'unit']; /** @var Decimal128|Int64|ResolvesToDate|ResolvesToNumber|UTCDateTime|float|int $input */ public readonly Decimal128|Int64|UTCDateTime|ResolvesToDate|ResolvesToNumber|float|int $input; diff --git a/src/Builder/Accumulator/ExpMovingAvgAccumulator.php b/src/Builder/Accumulator/ExpMovingAvgAccumulator.php index af12c817e..4231acb08 100644 --- a/src/Builder/Accumulator/ExpMovingAvgAccumulator.php +++ b/src/Builder/Accumulator/ExpMovingAvgAccumulator.php @@ -25,6 +25,7 @@ class ExpMovingAvgAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'N' => 'N', 'alpha' => 'alpha']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $input */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $input; diff --git a/src/Builder/Accumulator/FirstAccumulator.php b/src/Builder/Accumulator/FirstAccumulator.php index 559305d52..2a2ac1c36 100644 --- a/src/Builder/Accumulator/FirstAccumulator.php +++ b/src/Builder/Accumulator/FirstAccumulator.php @@ -25,6 +25,7 @@ class FirstAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/FirstNAccumulator.php b/src/Builder/Accumulator/FirstNAccumulator.php index 0100f1aed..0f8607752 100644 --- a/src/Builder/Accumulator/FirstNAccumulator.php +++ b/src/Builder/Accumulator/FirstNAccumulator.php @@ -27,6 +27,7 @@ class FirstNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'n' => 'n']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $input An expression that resolves to the array from which to return n elements. */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $input; diff --git a/src/Builder/Accumulator/IntegralAccumulator.php b/src/Builder/Accumulator/IntegralAccumulator.php index 5a5280ba2..6e66b2232 100644 --- a/src/Builder/Accumulator/IntegralAccumulator.php +++ b/src/Builder/Accumulator/IntegralAccumulator.php @@ -29,6 +29,7 @@ class IntegralAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'unit' => 'unit']; /** @var Decimal128|Int64|ResolvesToDate|ResolvesToNumber|UTCDateTime|float|int $input */ public readonly Decimal128|Int64|UTCDateTime|ResolvesToDate|ResolvesToNumber|float|int $input; diff --git a/src/Builder/Accumulator/LastAccumulator.php b/src/Builder/Accumulator/LastAccumulator.php index ab01fecdb..f94ce7759 100644 --- a/src/Builder/Accumulator/LastAccumulator.php +++ b/src/Builder/Accumulator/LastAccumulator.php @@ -25,6 +25,7 @@ class LastAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/LastNAccumulator.php b/src/Builder/Accumulator/LastNAccumulator.php index d0752f58d..b1be48efd 100644 --- a/src/Builder/Accumulator/LastNAccumulator.php +++ b/src/Builder/Accumulator/LastNAccumulator.php @@ -31,6 +31,7 @@ class LastNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'n' => 'n']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to the array from which to return n elements. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Accumulator/LinearFillAccumulator.php b/src/Builder/Accumulator/LinearFillAccumulator.php index e203f7ff9..8da65cfda 100644 --- a/src/Builder/Accumulator/LinearFillAccumulator.php +++ b/src/Builder/Accumulator/LinearFillAccumulator.php @@ -25,6 +25,7 @@ class LinearFillAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Accumulator/LocfAccumulator.php b/src/Builder/Accumulator/LocfAccumulator.php index e133cc4c9..5cfa9b6e7 100644 --- a/src/Builder/Accumulator/LocfAccumulator.php +++ b/src/Builder/Accumulator/LocfAccumulator.php @@ -25,6 +25,7 @@ class LocfAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/MaxAccumulator.php b/src/Builder/Accumulator/MaxAccumulator.php index 0258eb82b..29a7cb630 100644 --- a/src/Builder/Accumulator/MaxAccumulator.php +++ b/src/Builder/Accumulator/MaxAccumulator.php @@ -25,6 +25,7 @@ class MaxAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/MaxNAccumulator.php b/src/Builder/Accumulator/MaxNAccumulator.php index c952eedfa..551dc47f9 100644 --- a/src/Builder/Accumulator/MaxNAccumulator.php +++ b/src/Builder/Accumulator/MaxNAccumulator.php @@ -29,6 +29,7 @@ class MaxNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'n' => 'n']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to the array from which to return the maximal n elements. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Accumulator/MedianAccumulator.php b/src/Builder/Accumulator/MedianAccumulator.php index a81070700..aa4d92553 100644 --- a/src/Builder/Accumulator/MedianAccumulator.php +++ b/src/Builder/Accumulator/MedianAccumulator.php @@ -29,6 +29,7 @@ class MedianAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'method' => 'method']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $input $median calculates the 50th percentile value of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $median calculation ignores it. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $input; diff --git a/src/Builder/Accumulator/MergeObjectsAccumulator.php b/src/Builder/Accumulator/MergeObjectsAccumulator.php index 7f163e023..1922598a3 100644 --- a/src/Builder/Accumulator/MergeObjectsAccumulator.php +++ b/src/Builder/Accumulator/MergeObjectsAccumulator.php @@ -24,6 +24,7 @@ class MergeObjectsAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['document' => 'document']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $document Any valid expression that resolves to a document. */ public readonly Document|Serializable|ResolvesToObject|stdClass|array $document; diff --git a/src/Builder/Accumulator/MinAccumulator.php b/src/Builder/Accumulator/MinAccumulator.php index 9194c8866..7bb24dc0a 100644 --- a/src/Builder/Accumulator/MinAccumulator.php +++ b/src/Builder/Accumulator/MinAccumulator.php @@ -25,6 +25,7 @@ class MinAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/MinNAccumulator.php b/src/Builder/Accumulator/MinNAccumulator.php index dab804cc5..f9f87a116 100644 --- a/src/Builder/Accumulator/MinNAccumulator.php +++ b/src/Builder/Accumulator/MinNAccumulator.php @@ -29,6 +29,7 @@ class MinNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'n' => 'n']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to the array from which to return the maximal n elements. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Accumulator/PercentileAccumulator.php b/src/Builder/Accumulator/PercentileAccumulator.php index 85128f024..8c8cdb9ca 100644 --- a/src/Builder/Accumulator/PercentileAccumulator.php +++ b/src/Builder/Accumulator/PercentileAccumulator.php @@ -39,6 +39,7 @@ class PercentileAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'p' => 'p', 'method' => 'method']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $input $percentile calculates the percentile values of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $percentile calculation ignores it. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $input; diff --git a/src/Builder/Accumulator/PushAccumulator.php b/src/Builder/Accumulator/PushAccumulator.php index 3eb095670..192df40c2 100644 --- a/src/Builder/Accumulator/PushAccumulator.php +++ b/src/Builder/Accumulator/PushAccumulator.php @@ -25,6 +25,7 @@ class PushAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Accumulator/ShiftAccumulator.php b/src/Builder/Accumulator/ShiftAccumulator.php index c8533c140..257b11f36 100644 --- a/src/Builder/Accumulator/ShiftAccumulator.php +++ b/src/Builder/Accumulator/ShiftAccumulator.php @@ -24,6 +24,7 @@ class ShiftAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['output' => 'output', 'by' => 'by', 'default' => 'default']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $output Specifies an expression to evaluate and return in the output. */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $output; diff --git a/src/Builder/Accumulator/StdDevPopAccumulator.php b/src/Builder/Accumulator/StdDevPopAccumulator.php index 01fe39dff..1fadf83b9 100644 --- a/src/Builder/Accumulator/StdDevPopAccumulator.php +++ b/src/Builder/Accumulator/StdDevPopAccumulator.php @@ -26,6 +26,7 @@ class StdDevPopAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Accumulator/StdDevSampAccumulator.php b/src/Builder/Accumulator/StdDevSampAccumulator.php index 54adb4170..b48cdb0ac 100644 --- a/src/Builder/Accumulator/StdDevSampAccumulator.php +++ b/src/Builder/Accumulator/StdDevSampAccumulator.php @@ -26,6 +26,7 @@ class StdDevSampAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Accumulator/SumAccumulator.php b/src/Builder/Accumulator/SumAccumulator.php index faf0ace44..9e151c5c5 100644 --- a/src/Builder/Accumulator/SumAccumulator.php +++ b/src/Builder/Accumulator/SumAccumulator.php @@ -25,6 +25,7 @@ class SumAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Accumulator/TopAccumulator.php b/src/Builder/Accumulator/TopAccumulator.php index 135b8eb0a..dd0f5a717 100644 --- a/src/Builder/Accumulator/TopAccumulator.php +++ b/src/Builder/Accumulator/TopAccumulator.php @@ -28,6 +28,7 @@ class TopAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output']; /** @var Document|Serializable|array|stdClass $sortBy Specifies the order of results, with syntax similar to $sort. */ public readonly Document|Serializable|stdClass|array $sortBy; diff --git a/src/Builder/Accumulator/TopNAccumulator.php b/src/Builder/Accumulator/TopNAccumulator.php index ab8009121..e3e23abca 100644 --- a/src/Builder/Accumulator/TopNAccumulator.php +++ b/src/Builder/Accumulator/TopNAccumulator.php @@ -29,6 +29,7 @@ class TopNAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['n' => 'n', 'sortBy' => 'sortBy', 'output' => 'output']; /** @var ResolvesToInt|int $n limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. */ public readonly ResolvesToInt|int $n; diff --git a/src/Builder/Encoder/OperatorEncoder.php b/src/Builder/Encoder/OperatorEncoder.php index 69ef27c24..192d30740 100644 --- a/src/Builder/Encoder/OperatorEncoder.php +++ b/src/Builder/Encoder/OperatorEncoder.php @@ -5,7 +5,6 @@ namespace MongoDB\Builder\Encoder; use LogicException; -use MongoDB\Builder\Stage\GroupStage; use MongoDB\Builder\Type\Encode; use MongoDB\Builder\Type\OperatorInterface; use MongoDB\Builder\Type\Optional; @@ -13,12 +12,6 @@ use MongoDB\Exception\UnsupportedValueException; use stdClass; -use function array_key_exists; -use function assert; -use function get_object_vars; -use function is_array; -use function is_object; -use function property_exists; use function sprintf; /** @template-extends AbstractExpressionEncoder */ @@ -42,8 +35,6 @@ public function encode(mixed $value): stdClass Encode::Single => $this->encodeAsSingle($value), Encode::Array => $this->encodeAsArray($value), Encode::Object, Encode::FlatObject => $this->encodeAsObject($value), - Encode::DollarObject => $this->encodeAsDollarObject($value), - Encode::Group => $this->encodeAsGroup($value), default => throw new LogicException(sprintf('Class "%s" does not have a valid ENCODE constant.', $value::class)), }; } @@ -54,8 +45,8 @@ public function encode(mixed $value): stdClass private function encodeAsArray(OperatorInterface $value): stdClass { $result = []; - /** @var mixed $val */ - foreach (get_object_vars($value) as $val) { + foreach ($value::PROPERTIES as $prop => $name) { + $val = $value->$prop; // Skip optional arguments. For example, the $slice expression operator has an optional argument // in the middle of the array. if ($val === Optional::Undefined) { @@ -68,60 +59,29 @@ private function encodeAsArray(OperatorInterface $value): stdClass return $this->wrap($value, $result); } - private function encodeAsDollarObject(OperatorInterface $value): stdClass - { - $result = new stdClass(); - foreach (get_object_vars($value) as $key => $val) { - // Skip optional arguments. If they have a default value, it is resolved by the server. - if ($val === Optional::Undefined) { - continue; - } - - $val = $this->recursiveEncode($val); - - if ($key === 'geometry') { - if (is_object($val) && property_exists($val, '$geometry')) { - $result->{'$geometry'} = $val->{'$geometry'}; - } elseif (is_array($val) && array_key_exists('$geometry', $val)) { - $result->{'$geometry'} = $val['$geometry']; - } else { - $result->{'$geometry'} = $val; - } - } else { - $result->{'$' . $key} = $val; - } - } - - return $this->wrap($value, $result); - } - /** - * $group stage have a specific encoding because the _id argument is required and others are variadic + * Encode the value as an object with properties. Property names are + * mapped by the PROPERTIES constant. */ - private function encodeAsGroup(OperatorInterface $value): stdClass - { - assert($value instanceof GroupStage); - - $result = new stdClass(); - $result->_id = $this->recursiveEncode($value->_id); - - foreach (get_object_vars($value->field) as $key => $val) { - $result->{$key} = $this->recursiveEncode($val); - } - - return $this->wrap($value, $result); - } - private function encodeAsObject(OperatorInterface $value): stdClass { $result = new stdClass(); - foreach (get_object_vars($value) as $key => $val) { + foreach ($value::PROPERTIES as $prop => $name) { + $val = $value->$prop; + // Skip optional arguments. If they have a default value, it is resolved by the server. if ($val === Optional::Undefined) { continue; } - $result->{$key} = $this->recursiveEncode($val); + if ($name === null) { + $val = $this->recursiveEncode($val); + foreach ($val as $k => $v) { + $result->{$k} = $v; + } + } else { + $result->{$name} = $this->recursiveEncode($val); + } } return $value::ENCODE === Encode::FlatObject @@ -134,8 +94,8 @@ private function encodeAsObject(OperatorInterface $value): stdClass */ private function encodeAsSingle(OperatorInterface $value): stdClass { - foreach (get_object_vars($value) as $val) { - $result = $this->recursiveEncode($val); + foreach ($value::PROPERTIES as $prop => $name) { + $result = $this->recursiveEncode($value->$prop); return $this->wrap($value, $result); } diff --git a/src/Builder/Expression/AbsOperator.php b/src/Builder/Expression/AbsOperator.php index df28a0d3d..b187d31c2 100644 --- a/src/Builder/Expression/AbsOperator.php +++ b/src/Builder/Expression/AbsOperator.php @@ -21,6 +21,7 @@ class AbsOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $value */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $value; diff --git a/src/Builder/Expression/AcosOperator.php b/src/Builder/Expression/AcosOperator.php index 38a12b6c4..60a30b6d3 100644 --- a/src/Builder/Expression/AcosOperator.php +++ b/src/Builder/Expression/AcosOperator.php @@ -21,6 +21,7 @@ class AcosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $acos takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. diff --git a/src/Builder/Expression/AcoshOperator.php b/src/Builder/Expression/AcoshOperator.php index ba956df43..d0cc50c92 100644 --- a/src/Builder/Expression/AcoshOperator.php +++ b/src/Builder/Expression/AcoshOperator.php @@ -21,6 +21,7 @@ class AcoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $acosh takes any valid expression that resolves to a number between 1 and +Infinity, e.g. 1 <= value <= +Infinity. diff --git a/src/Builder/Expression/AddOperator.php b/src/Builder/Expression/AddOperator.php index 580731680..5437e6dac 100644 --- a/src/Builder/Expression/AddOperator.php +++ b/src/Builder/Expression/AddOperator.php @@ -25,6 +25,7 @@ class AddOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date. */ public readonly array $expression; diff --git a/src/Builder/Expression/AllElementsTrueOperator.php b/src/Builder/Expression/AllElementsTrueOperator.php index dbfebe75c..27430149a 100644 --- a/src/Builder/Expression/AllElementsTrueOperator.php +++ b/src/Builder/Expression/AllElementsTrueOperator.php @@ -25,6 +25,7 @@ class AllElementsTrueOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/AndOperator.php b/src/Builder/Expression/AndOperator.php index c4f3d7e6c..e6bdc6f31 100644 --- a/src/Builder/Expression/AndOperator.php +++ b/src/Builder/Expression/AndOperator.php @@ -27,6 +27,7 @@ class AndOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/AnyElementTrueOperator.php b/src/Builder/Expression/AnyElementTrueOperator.php index 68cef3242..ec80ca8fc 100644 --- a/src/Builder/Expression/AnyElementTrueOperator.php +++ b/src/Builder/Expression/AnyElementTrueOperator.php @@ -25,6 +25,7 @@ class AnyElementTrueOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/ArrayElemAtOperator.php b/src/Builder/Expression/ArrayElemAtOperator.php index e7fd09073..32f84ac83 100644 --- a/src/Builder/Expression/ArrayElemAtOperator.php +++ b/src/Builder/Expression/ArrayElemAtOperator.php @@ -25,6 +25,7 @@ class ArrayElemAtOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['array' => 'array', 'idx' => 'idx']; /** @var BSONArray|PackedArray|ResolvesToArray|array $array */ public readonly PackedArray|ResolvesToArray|BSONArray|array $array; diff --git a/src/Builder/Expression/ArrayToObjectOperator.php b/src/Builder/Expression/ArrayToObjectOperator.php index 4c6935875..dfaf70002 100644 --- a/src/Builder/Expression/ArrayToObjectOperator.php +++ b/src/Builder/Expression/ArrayToObjectOperator.php @@ -25,6 +25,7 @@ class ArrayToObjectOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['array' => 'array']; /** @var BSONArray|PackedArray|ResolvesToArray|array $array */ public readonly PackedArray|ResolvesToArray|BSONArray|array $array; diff --git a/src/Builder/Expression/AsinOperator.php b/src/Builder/Expression/AsinOperator.php index f46031231..e7f144ff9 100644 --- a/src/Builder/Expression/AsinOperator.php +++ b/src/Builder/Expression/AsinOperator.php @@ -21,6 +21,7 @@ class AsinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $asin takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. diff --git a/src/Builder/Expression/AsinhOperator.php b/src/Builder/Expression/AsinhOperator.php index ab466a0d8..e53bacf34 100644 --- a/src/Builder/Expression/AsinhOperator.php +++ b/src/Builder/Expression/AsinhOperator.php @@ -21,6 +21,7 @@ class AsinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $asinh takes any valid expression that resolves to a number. diff --git a/src/Builder/Expression/Atan2Operator.php b/src/Builder/Expression/Atan2Operator.php index c08e7fbf8..a5bd626f7 100644 --- a/src/Builder/Expression/Atan2Operator.php +++ b/src/Builder/Expression/Atan2Operator.php @@ -21,6 +21,7 @@ class Atan2Operator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['y' => 'y', 'x' => 'x']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $y $atan2 takes any valid expression that resolves to a number. diff --git a/src/Builder/Expression/AtanOperator.php b/src/Builder/Expression/AtanOperator.php index b6d99973d..a41095dd1 100644 --- a/src/Builder/Expression/AtanOperator.php +++ b/src/Builder/Expression/AtanOperator.php @@ -21,6 +21,7 @@ class AtanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $atan takes any valid expression that resolves to a number. diff --git a/src/Builder/Expression/AtanhOperator.php b/src/Builder/Expression/AtanhOperator.php index 38b9208f6..f1f3ed1a5 100644 --- a/src/Builder/Expression/AtanhOperator.php +++ b/src/Builder/Expression/AtanhOperator.php @@ -21,6 +21,7 @@ class AtanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $atanh takes any valid expression that resolves to a number between -1 and 1, e.g. -1 <= value <= 1. diff --git a/src/Builder/Expression/AvgOperator.php b/src/Builder/Expression/AvgOperator.php index 898bbe252..457d3c278 100644 --- a/src/Builder/Expression/AvgOperator.php +++ b/src/Builder/Expression/AvgOperator.php @@ -25,6 +25,7 @@ class AvgOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/BinarySizeOperator.php b/src/Builder/Expression/BinarySizeOperator.php index 28293cc88..7cb22f5e5 100644 --- a/src/Builder/Expression/BinarySizeOperator.php +++ b/src/Builder/Expression/BinarySizeOperator.php @@ -20,6 +20,7 @@ class BinarySizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Binary|ResolvesToBinData|ResolvesToNull|ResolvesToString|null|string $expression */ public readonly Binary|ResolvesToBinData|ResolvesToNull|ResolvesToString|null|string $expression; diff --git a/src/Builder/Expression/BitAndOperator.php b/src/Builder/Expression/BitAndOperator.php index 97b910a3f..09f02b2a6 100644 --- a/src/Builder/Expression/BitAndOperator.php +++ b/src/Builder/Expression/BitAndOperator.php @@ -24,6 +24,7 @@ class BitAndOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/BitNotOperator.php b/src/Builder/Expression/BitNotOperator.php index d75322971..364c8e982 100644 --- a/src/Builder/Expression/BitNotOperator.php +++ b/src/Builder/Expression/BitNotOperator.php @@ -21,6 +21,7 @@ class BitNotOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Int64|ResolvesToInt|ResolvesToLong|int $expression */ public readonly Int64|ResolvesToInt|ResolvesToLong|int $expression; diff --git a/src/Builder/Expression/BitOrOperator.php b/src/Builder/Expression/BitOrOperator.php index f14ac9583..ab5a41a20 100644 --- a/src/Builder/Expression/BitOrOperator.php +++ b/src/Builder/Expression/BitOrOperator.php @@ -24,6 +24,7 @@ class BitOrOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/BitXorOperator.php b/src/Builder/Expression/BitXorOperator.php index 5382065b6..fd380961e 100644 --- a/src/Builder/Expression/BitXorOperator.php +++ b/src/Builder/Expression/BitXorOperator.php @@ -24,6 +24,7 @@ class BitXorOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/BsonSizeOperator.php b/src/Builder/Expression/BsonSizeOperator.php index bdfb6f694..15105176c 100644 --- a/src/Builder/Expression/BsonSizeOperator.php +++ b/src/Builder/Expression/BsonSizeOperator.php @@ -22,6 +22,7 @@ class BsonSizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['object' => 'object']; /** @var Document|ResolvesToNull|ResolvesToObject|Serializable|array|null|stdClass $object */ public readonly Document|Serializable|ResolvesToNull|ResolvesToObject|stdClass|array|null $object; diff --git a/src/Builder/Expression/CaseOperator.php b/src/Builder/Expression/CaseOperator.php index 463a3b741..6f5c293d1 100644 --- a/src/Builder/Expression/CaseOperator.php +++ b/src/Builder/Expression/CaseOperator.php @@ -23,6 +23,7 @@ class CaseOperator implements SwitchBranchInterface, OperatorInterface { public const ENCODE = Encode::FlatObject; + public const PROPERTIES = ['case' => 'case', 'then' => 'then']; /** @var ResolvesToBool|bool $case Can be any valid expression that resolves to a boolean. If the result is not a boolean, it is coerced to a boolean value. More information about how MongoDB evaluates expressions as either true or false can be found here. */ public readonly ResolvesToBool|bool $case; diff --git a/src/Builder/Expression/CeilOperator.php b/src/Builder/Expression/CeilOperator.php index 95a01aa14..e6308dee4 100644 --- a/src/Builder/Expression/CeilOperator.php +++ b/src/Builder/Expression/CeilOperator.php @@ -21,6 +21,7 @@ class CeilOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression If the argument resolves to a value of null or refers to a field that is missing, $ceil returns null. If the argument resolves to NaN, $ceil returns NaN. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Expression/CmpOperator.php b/src/Builder/Expression/CmpOperator.php index 78354cb20..41f3636e1 100644 --- a/src/Builder/Expression/CmpOperator.php +++ b/src/Builder/Expression/CmpOperator.php @@ -22,6 +22,7 @@ class CmpOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/ConcatArraysOperator.php b/src/Builder/Expression/ConcatArraysOperator.php index f8b790d52..215d06071 100644 --- a/src/Builder/Expression/ConcatArraysOperator.php +++ b/src/Builder/Expression/ConcatArraysOperator.php @@ -24,6 +24,7 @@ class ConcatArraysOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['array' => 'array']; /** @var list $array */ public readonly array $array; diff --git a/src/Builder/Expression/ConcatOperator.php b/src/Builder/Expression/ConcatOperator.php index d9f0d9168..fcec6e26b 100644 --- a/src/Builder/Expression/ConcatOperator.php +++ b/src/Builder/Expression/ConcatOperator.php @@ -22,6 +22,7 @@ class ConcatOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/CondOperator.php b/src/Builder/Expression/CondOperator.php index 1d3a44c58..67a92f987 100644 --- a/src/Builder/Expression/CondOperator.php +++ b/src/Builder/Expression/CondOperator.php @@ -22,6 +22,7 @@ class CondOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['if' => 'if', 'then' => 'then', 'else' => 'else']; /** @var ResolvesToBool|bool $if */ public readonly ResolvesToBool|bool $if; diff --git a/src/Builder/Expression/ConvertOperator.php b/src/Builder/Expression/ConvertOperator.php index f8cb5210e..ee48fb04f 100644 --- a/src/Builder/Expression/ConvertOperator.php +++ b/src/Builder/Expression/ConvertOperator.php @@ -24,6 +24,7 @@ class ConvertOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'to' => 'to', 'onError' => 'onError', 'onNull' => 'onNull']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $input */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $input; diff --git a/src/Builder/Expression/CosOperator.php b/src/Builder/Expression/CosOperator.php index d3fe010e2..42657efe2 100644 --- a/src/Builder/Expression/CosOperator.php +++ b/src/Builder/Expression/CosOperator.php @@ -21,6 +21,7 @@ class CosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $cos takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. diff --git a/src/Builder/Expression/CoshOperator.php b/src/Builder/Expression/CoshOperator.php index 53530064f..f72d1d652 100644 --- a/src/Builder/Expression/CoshOperator.php +++ b/src/Builder/Expression/CoshOperator.php @@ -21,6 +21,7 @@ class CoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $cosh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. diff --git a/src/Builder/Expression/DateAddOperator.php b/src/Builder/Expression/DateAddOperator.php index b68484663..3032f0134 100644 --- a/src/Builder/Expression/DateAddOperator.php +++ b/src/Builder/Expression/DateAddOperator.php @@ -25,6 +25,7 @@ class DateAddOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['startDate' => 'startDate', 'unit' => 'unit', 'amount' => 'amount', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $startDate The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $startDate; diff --git a/src/Builder/Expression/DateDiffOperator.php b/src/Builder/Expression/DateDiffOperator.php index a13e484fc..482c1d830 100644 --- a/src/Builder/Expression/DateDiffOperator.php +++ b/src/Builder/Expression/DateDiffOperator.php @@ -25,6 +25,14 @@ class DateDiffOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'startDate' => 'startDate', + 'endDate' => 'endDate', + 'unit' => 'unit', + 'timezone' => 'timezone', + 'startOfWeek' => 'startOfWeek', + ]; + /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $startDate The start of the time period. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $startDate; diff --git a/src/Builder/Expression/DateFromPartsOperator.php b/src/Builder/Expression/DateFromPartsOperator.php index f8b7ad639..1716b93e7 100644 --- a/src/Builder/Expression/DateFromPartsOperator.php +++ b/src/Builder/Expression/DateFromPartsOperator.php @@ -23,6 +23,20 @@ class DateFromPartsOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'year' => 'year', + 'isoWeekYear' => 'isoWeekYear', + 'month' => 'month', + 'isoWeek' => 'isoWeek', + 'day' => 'day', + 'isoDayOfWeek' => 'isoDayOfWeek', + 'hour' => 'hour', + 'minute' => 'minute', + 'second' => 'second', + 'millisecond' => 'millisecond', + 'timezone' => 'timezone', + ]; + /** @var Optional|Decimal128|Int64|ResolvesToNumber|float|int $year Calendar year. Can be any expression that evaluates to a number. */ public readonly Optional|Decimal128|Int64|ResolvesToNumber|float|int $year; diff --git a/src/Builder/Expression/DateFromStringOperator.php b/src/Builder/Expression/DateFromStringOperator.php index 5a3f808f0..493914b72 100644 --- a/src/Builder/Expression/DateFromStringOperator.php +++ b/src/Builder/Expression/DateFromStringOperator.php @@ -24,6 +24,14 @@ class DateFromStringOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'dateString' => 'dateString', + 'format' => 'format', + 'timezone' => 'timezone', + 'onError' => 'onError', + 'onNull' => 'onNull', + ]; + /** @var ResolvesToString|string $dateString The date/time string to convert to a date object. */ public readonly ResolvesToString|string $dateString; diff --git a/src/Builder/Expression/DateSubtractOperator.php b/src/Builder/Expression/DateSubtractOperator.php index 90efa4846..2354e2257 100644 --- a/src/Builder/Expression/DateSubtractOperator.php +++ b/src/Builder/Expression/DateSubtractOperator.php @@ -25,6 +25,7 @@ class DateSubtractOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['startDate' => 'startDate', 'unit' => 'unit', 'amount' => 'amount', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $startDate The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $startDate; diff --git a/src/Builder/Expression/DateToPartsOperator.php b/src/Builder/Expression/DateToPartsOperator.php index c0f637259..0b750653d 100644 --- a/src/Builder/Expression/DateToPartsOperator.php +++ b/src/Builder/Expression/DateToPartsOperator.php @@ -23,6 +23,7 @@ class DateToPartsOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone', 'iso8601' => 'iso8601']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The input date for which to return parts. date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/DateToStringOperator.php b/src/Builder/Expression/DateToStringOperator.php index e33c519fd..5950592bc 100644 --- a/src/Builder/Expression/DateToStringOperator.php +++ b/src/Builder/Expression/DateToStringOperator.php @@ -26,6 +26,7 @@ class DateToStringOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'format' => 'format', 'timezone' => 'timezone', 'onNull' => 'onNull']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to convert to string. Must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/DateTruncOperator.php b/src/Builder/Expression/DateTruncOperator.php index 78be17040..2a535fab6 100644 --- a/src/Builder/Expression/DateTruncOperator.php +++ b/src/Builder/Expression/DateTruncOperator.php @@ -27,6 +27,14 @@ class DateTruncOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'date' => 'date', + 'unit' => 'unit', + 'binSize' => 'binSize', + 'timezone' => 'timezone', + 'startOfWeek' => 'startOfWeek', + ]; + /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to truncate, specified in UTC. The date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/DayOfMonthOperator.php b/src/Builder/Expression/DayOfMonthOperator.php index a1a06db6b..ed455bfd3 100644 --- a/src/Builder/Expression/DayOfMonthOperator.php +++ b/src/Builder/Expression/DayOfMonthOperator.php @@ -23,6 +23,7 @@ class DayOfMonthOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/DayOfWeekOperator.php b/src/Builder/Expression/DayOfWeekOperator.php index 8b439c02c..b3bc1f58f 100644 --- a/src/Builder/Expression/DayOfWeekOperator.php +++ b/src/Builder/Expression/DayOfWeekOperator.php @@ -23,6 +23,7 @@ class DayOfWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/DayOfYearOperator.php b/src/Builder/Expression/DayOfYearOperator.php index d97be270d..a7f38720a 100644 --- a/src/Builder/Expression/DayOfYearOperator.php +++ b/src/Builder/Expression/DayOfYearOperator.php @@ -23,6 +23,7 @@ class DayOfYearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/DegreesToRadiansOperator.php b/src/Builder/Expression/DegreesToRadiansOperator.php index a9329e16e..b38a82c74 100644 --- a/src/Builder/Expression/DegreesToRadiansOperator.php +++ b/src/Builder/Expression/DegreesToRadiansOperator.php @@ -21,6 +21,7 @@ class DegreesToRadiansOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $degreesToRadians takes any valid expression that resolves to a number. diff --git a/src/Builder/Expression/DivideOperator.php b/src/Builder/Expression/DivideOperator.php index bda2f503a..36164e985 100644 --- a/src/Builder/Expression/DivideOperator.php +++ b/src/Builder/Expression/DivideOperator.php @@ -21,6 +21,7 @@ class DivideOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['dividend' => 'dividend', 'divisor' => 'divisor']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $dividend The first argument is the dividend, and the second argument is the divisor; i.e. the first argument is divided by the second argument. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $dividend; diff --git a/src/Builder/Expression/EqOperator.php b/src/Builder/Expression/EqOperator.php index 5da15a3c3..f87e35c85 100644 --- a/src/Builder/Expression/EqOperator.php +++ b/src/Builder/Expression/EqOperator.php @@ -22,6 +22,7 @@ class EqOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/ExpOperator.php b/src/Builder/Expression/ExpOperator.php index a168a6acd..6c9053625 100644 --- a/src/Builder/Expression/ExpOperator.php +++ b/src/Builder/Expression/ExpOperator.php @@ -21,6 +21,7 @@ class ExpOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['exponent' => 'exponent']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $exponent */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $exponent; diff --git a/src/Builder/Expression/FilterOperator.php b/src/Builder/Expression/FilterOperator.php index 6fc372e06..4ca176f90 100644 --- a/src/Builder/Expression/FilterOperator.php +++ b/src/Builder/Expression/FilterOperator.php @@ -26,6 +26,7 @@ class FilterOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'cond' => 'cond', 'as' => 'as', 'limit' => 'limit']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Expression/FirstNOperator.php b/src/Builder/Expression/FirstNOperator.php index 7aeb04eba..e999ec479 100644 --- a/src/Builder/Expression/FirstNOperator.php +++ b/src/Builder/Expression/FirstNOperator.php @@ -25,6 +25,7 @@ class FirstNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['n' => 'n', 'input' => 'input']; /** @var ResolvesToInt|int $n An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. */ public readonly ResolvesToInt|int $n; diff --git a/src/Builder/Expression/FirstOperator.php b/src/Builder/Expression/FirstOperator.php index 5453af68f..cf4b807da 100644 --- a/src/Builder/Expression/FirstOperator.php +++ b/src/Builder/Expression/FirstOperator.php @@ -25,6 +25,7 @@ class FirstOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/FloorOperator.php b/src/Builder/Expression/FloorOperator.php index 4dfac2de1..015adb45e 100644 --- a/src/Builder/Expression/FloorOperator.php +++ b/src/Builder/Expression/FloorOperator.php @@ -21,6 +21,7 @@ class FloorOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Expression/FunctionOperator.php b/src/Builder/Expression/FunctionOperator.php index 2a59fd6a3..c06790010 100644 --- a/src/Builder/Expression/FunctionOperator.php +++ b/src/Builder/Expression/FunctionOperator.php @@ -28,6 +28,7 @@ class FunctionOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['body' => 'body', 'args' => 'args', 'lang' => 'lang']; /** * @var Javascript|string $body The function definition. You can specify the function definition as either BSON\JavaScript or string. diff --git a/src/Builder/Expression/GetFieldOperator.php b/src/Builder/Expression/GetFieldOperator.php index 45007b3fd..8a0efe6a4 100644 --- a/src/Builder/Expression/GetFieldOperator.php +++ b/src/Builder/Expression/GetFieldOperator.php @@ -24,6 +24,7 @@ class GetFieldOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['field' => 'field', 'input' => 'input']; /** * @var ResolvesToString|string $field Field in the input object for which you want to return a value. field can be any valid expression that resolves to a string constant. diff --git a/src/Builder/Expression/GtOperator.php b/src/Builder/Expression/GtOperator.php index 1f4287eaa..27c66ecee 100644 --- a/src/Builder/Expression/GtOperator.php +++ b/src/Builder/Expression/GtOperator.php @@ -22,6 +22,7 @@ class GtOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/GteOperator.php b/src/Builder/Expression/GteOperator.php index 8ed633ae8..d3a37100b 100644 --- a/src/Builder/Expression/GteOperator.php +++ b/src/Builder/Expression/GteOperator.php @@ -22,6 +22,7 @@ class GteOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/HourOperator.php b/src/Builder/Expression/HourOperator.php index 2d0598589..f13dce737 100644 --- a/src/Builder/Expression/HourOperator.php +++ b/src/Builder/Expression/HourOperator.php @@ -23,6 +23,7 @@ class HourOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/IfNullOperator.php b/src/Builder/Expression/IfNullOperator.php index f0a6a9ced..60cb20a71 100644 --- a/src/Builder/Expression/IfNullOperator.php +++ b/src/Builder/Expression/IfNullOperator.php @@ -25,6 +25,7 @@ class IfNullOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/InOperator.php b/src/Builder/Expression/InOperator.php index 90ddab23b..a16badda9 100644 --- a/src/Builder/Expression/InOperator.php +++ b/src/Builder/Expression/InOperator.php @@ -28,6 +28,7 @@ class InOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression' => 'expression', 'array' => 'array']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression Any valid expression expression. */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/IndexOfArrayOperator.php b/src/Builder/Expression/IndexOfArrayOperator.php index d04497fb5..ac9eaef94 100644 --- a/src/Builder/Expression/IndexOfArrayOperator.php +++ b/src/Builder/Expression/IndexOfArrayOperator.php @@ -29,6 +29,7 @@ class IndexOfArrayOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['array' => 'array', 'search' => 'search', 'start' => 'start', 'end' => 'end']; /** * @var BSONArray|PackedArray|ResolvesToArray|array $array Can be any valid expression as long as it resolves to an array. diff --git a/src/Builder/Expression/IndexOfBytesOperator.php b/src/Builder/Expression/IndexOfBytesOperator.php index ce778fa25..e77706a5c 100644 --- a/src/Builder/Expression/IndexOfBytesOperator.php +++ b/src/Builder/Expression/IndexOfBytesOperator.php @@ -20,6 +20,7 @@ class IndexOfBytesOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['string' => 'string', 'substring' => 'substring', 'start' => 'start', 'end' => 'end']; /** * @var ResolvesToString|string $string Can be any valid expression as long as it resolves to a string. diff --git a/src/Builder/Expression/IndexOfCPOperator.php b/src/Builder/Expression/IndexOfCPOperator.php index c4fd80d88..3542a7f8d 100644 --- a/src/Builder/Expression/IndexOfCPOperator.php +++ b/src/Builder/Expression/IndexOfCPOperator.php @@ -20,6 +20,7 @@ class IndexOfCPOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['string' => 'string', 'substring' => 'substring', 'start' => 'start', 'end' => 'end']; /** * @var ResolvesToString|string $string Can be any valid expression as long as it resolves to a string. diff --git a/src/Builder/Expression/IsArrayOperator.php b/src/Builder/Expression/IsArrayOperator.php index bb15c0102..81fce561e 100644 --- a/src/Builder/Expression/IsArrayOperator.php +++ b/src/Builder/Expression/IsArrayOperator.php @@ -22,6 +22,7 @@ class IsArrayOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/IsNumberOperator.php b/src/Builder/Expression/IsNumberOperator.php index 9d778f66f..a8586a21c 100644 --- a/src/Builder/Expression/IsNumberOperator.php +++ b/src/Builder/Expression/IsNumberOperator.php @@ -24,6 +24,7 @@ class IsNumberOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/IsoDayOfWeekOperator.php b/src/Builder/Expression/IsoDayOfWeekOperator.php index ac55ea6ba..fdfdd74cb 100644 --- a/src/Builder/Expression/IsoDayOfWeekOperator.php +++ b/src/Builder/Expression/IsoDayOfWeekOperator.php @@ -23,6 +23,7 @@ class IsoDayOfWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/IsoWeekOperator.php b/src/Builder/Expression/IsoWeekOperator.php index af6cca475..8801293fd 100644 --- a/src/Builder/Expression/IsoWeekOperator.php +++ b/src/Builder/Expression/IsoWeekOperator.php @@ -23,6 +23,7 @@ class IsoWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/IsoWeekYearOperator.php b/src/Builder/Expression/IsoWeekYearOperator.php index a23d90696..946be3836 100644 --- a/src/Builder/Expression/IsoWeekYearOperator.php +++ b/src/Builder/Expression/IsoWeekYearOperator.php @@ -23,6 +23,7 @@ class IsoWeekYearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/LastNOperator.php b/src/Builder/Expression/LastNOperator.php index f1bbaab11..9e820061f 100644 --- a/src/Builder/Expression/LastNOperator.php +++ b/src/Builder/Expression/LastNOperator.php @@ -25,6 +25,7 @@ class LastNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['n' => 'n', 'input' => 'input']; /** @var ResolvesToInt|int $n An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. */ public readonly ResolvesToInt|int $n; diff --git a/src/Builder/Expression/LastOperator.php b/src/Builder/Expression/LastOperator.php index ea622018c..a8ba3ed16 100644 --- a/src/Builder/Expression/LastOperator.php +++ b/src/Builder/Expression/LastOperator.php @@ -25,6 +25,7 @@ class LastOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/LetOperator.php b/src/Builder/Expression/LetOperator.php index 541b0b8ff..0e9ead011 100644 --- a/src/Builder/Expression/LetOperator.php +++ b/src/Builder/Expression/LetOperator.php @@ -25,6 +25,7 @@ class LetOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['vars' => 'vars', 'in' => 'in']; /** * @var Document|Serializable|array|stdClass $vars Assignment block for the variables accessible in the in expression. To assign a variable, specify a string for the variable name and assign a valid expression for the value. diff --git a/src/Builder/Expression/LiteralOperator.php b/src/Builder/Expression/LiteralOperator.php index 95e942b2f..9f56638a8 100644 --- a/src/Builder/Expression/LiteralOperator.php +++ b/src/Builder/Expression/LiteralOperator.php @@ -21,6 +21,7 @@ class LiteralOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value If the value is an expression, $literal does not evaluate the expression but instead returns the unparsed expression. */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Expression/LnOperator.php b/src/Builder/Expression/LnOperator.php index 43d0de15b..ca6977fb7 100644 --- a/src/Builder/Expression/LnOperator.php +++ b/src/Builder/Expression/LnOperator.php @@ -22,6 +22,7 @@ class LnOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['number' => 'number']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $number Any valid expression as long as it resolves to a non-negative number. For more information on expressions, see Expressions. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $number; diff --git a/src/Builder/Expression/Log10Operator.php b/src/Builder/Expression/Log10Operator.php index ccdc67666..d7b9c83b2 100644 --- a/src/Builder/Expression/Log10Operator.php +++ b/src/Builder/Expression/Log10Operator.php @@ -21,6 +21,7 @@ class Log10Operator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['number' => 'number']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $number Any valid expression as long as it resolves to a non-negative number. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $number; diff --git a/src/Builder/Expression/LogOperator.php b/src/Builder/Expression/LogOperator.php index 8359e1a53..6ff8bcdc1 100644 --- a/src/Builder/Expression/LogOperator.php +++ b/src/Builder/Expression/LogOperator.php @@ -21,6 +21,7 @@ class LogOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['number' => 'number', 'base' => 'base']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $number Any valid expression as long as it resolves to a non-negative number. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $number; diff --git a/src/Builder/Expression/LtOperator.php b/src/Builder/Expression/LtOperator.php index a3cbad988..b8c47aef3 100644 --- a/src/Builder/Expression/LtOperator.php +++ b/src/Builder/Expression/LtOperator.php @@ -22,6 +22,7 @@ class LtOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/LteOperator.php b/src/Builder/Expression/LteOperator.php index 10e3d299a..13843dc36 100644 --- a/src/Builder/Expression/LteOperator.php +++ b/src/Builder/Expression/LteOperator.php @@ -22,6 +22,7 @@ class LteOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/LtrimOperator.php b/src/Builder/Expression/LtrimOperator.php index a0f4b7a5a..1a2027753 100644 --- a/src/Builder/Expression/LtrimOperator.php +++ b/src/Builder/Expression/LtrimOperator.php @@ -21,6 +21,7 @@ class LtrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'chars' => 'chars']; /** @var ResolvesToString|string $input The string to trim. The argument can be any valid expression that resolves to a string. */ public readonly ResolvesToString|string $input; diff --git a/src/Builder/Expression/MapOperator.php b/src/Builder/Expression/MapOperator.php index 98274395c..35ddc7d01 100644 --- a/src/Builder/Expression/MapOperator.php +++ b/src/Builder/Expression/MapOperator.php @@ -29,6 +29,7 @@ class MapOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'in' => 'in', 'as' => 'as']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to an array. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Expression/MaxNOperator.php b/src/Builder/Expression/MaxNOperator.php index 2cda849d7..bf07fec41 100644 --- a/src/Builder/Expression/MaxNOperator.php +++ b/src/Builder/Expression/MaxNOperator.php @@ -25,6 +25,7 @@ class MaxNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'n' => 'n']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to the array from which to return the maximal n elements. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Expression/MaxOperator.php b/src/Builder/Expression/MaxOperator.php index 0573929b6..a04e56281 100644 --- a/src/Builder/Expression/MaxOperator.php +++ b/src/Builder/Expression/MaxOperator.php @@ -26,6 +26,7 @@ class MaxOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/MedianOperator.php b/src/Builder/Expression/MedianOperator.php index f9c4f458d..1432737a3 100644 --- a/src/Builder/Expression/MedianOperator.php +++ b/src/Builder/Expression/MedianOperator.php @@ -32,6 +32,7 @@ class MedianOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'method' => 'method']; /** @var BSONArray|Decimal128|Int64|PackedArray|ResolvesToNumber|array|float|int $input $median calculates the 50th percentile value of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $median calculation ignores it. */ public readonly Decimal128|Int64|PackedArray|ResolvesToNumber|BSONArray|array|float|int $input; diff --git a/src/Builder/Expression/MergeObjectsOperator.php b/src/Builder/Expression/MergeObjectsOperator.php index 162f2cd49..d92390760 100644 --- a/src/Builder/Expression/MergeObjectsOperator.php +++ b/src/Builder/Expression/MergeObjectsOperator.php @@ -25,6 +25,7 @@ class MergeObjectsOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['document' => 'document']; /** @var list $document Any valid expression that resolves to a document. */ public readonly array $document; diff --git a/src/Builder/Expression/MetaOperator.php b/src/Builder/Expression/MetaOperator.php index a02b54ee9..ab39b4267 100644 --- a/src/Builder/Expression/MetaOperator.php +++ b/src/Builder/Expression/MetaOperator.php @@ -19,6 +19,7 @@ class MetaOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['keyword' => 'keyword']; /** @var string $keyword */ public readonly string $keyword; diff --git a/src/Builder/Expression/MillisecondOperator.php b/src/Builder/Expression/MillisecondOperator.php index 63b53b460..9e111e800 100644 --- a/src/Builder/Expression/MillisecondOperator.php +++ b/src/Builder/Expression/MillisecondOperator.php @@ -23,6 +23,7 @@ class MillisecondOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/MinNOperator.php b/src/Builder/Expression/MinNOperator.php index f47976cb5..a2bb782bf 100644 --- a/src/Builder/Expression/MinNOperator.php +++ b/src/Builder/Expression/MinNOperator.php @@ -25,6 +25,7 @@ class MinNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'n' => 'n']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to the array from which to return the maximal n elements. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $input; diff --git a/src/Builder/Expression/MinOperator.php b/src/Builder/Expression/MinOperator.php index c3fa2ed4b..23fa3a5c1 100644 --- a/src/Builder/Expression/MinOperator.php +++ b/src/Builder/Expression/MinOperator.php @@ -26,6 +26,7 @@ class MinOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/MinuteOperator.php b/src/Builder/Expression/MinuteOperator.php index 7ab514ed0..494b2c061 100644 --- a/src/Builder/Expression/MinuteOperator.php +++ b/src/Builder/Expression/MinuteOperator.php @@ -23,6 +23,7 @@ class MinuteOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/ModOperator.php b/src/Builder/Expression/ModOperator.php index 1a01019d7..bf0565c6e 100644 --- a/src/Builder/Expression/ModOperator.php +++ b/src/Builder/Expression/ModOperator.php @@ -21,6 +21,7 @@ class ModOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['dividend' => 'dividend', 'divisor' => 'divisor']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $dividend The first argument is the dividend, and the second argument is the divisor; i.e. first argument is divided by the second argument. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $dividend; diff --git a/src/Builder/Expression/MonthOperator.php b/src/Builder/Expression/MonthOperator.php index 531bc946a..2ea56f1b1 100644 --- a/src/Builder/Expression/MonthOperator.php +++ b/src/Builder/Expression/MonthOperator.php @@ -23,6 +23,7 @@ class MonthOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/MultiplyOperator.php b/src/Builder/Expression/MultiplyOperator.php index 9f15aeb39..8cf1d6814 100644 --- a/src/Builder/Expression/MultiplyOperator.php +++ b/src/Builder/Expression/MultiplyOperator.php @@ -24,6 +24,7 @@ class MultiplyOperator implements ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var list $expression The arguments can be any valid expression as long as they resolve to numbers. diff --git a/src/Builder/Expression/NeOperator.php b/src/Builder/Expression/NeOperator.php index 7bc322571..935a9e919 100644 --- a/src/Builder/Expression/NeOperator.php +++ b/src/Builder/Expression/NeOperator.php @@ -22,6 +22,7 @@ class NeOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression1; diff --git a/src/Builder/Expression/NotOperator.php b/src/Builder/Expression/NotOperator.php index 170538e15..1849be93b 100644 --- a/src/Builder/Expression/NotOperator.php +++ b/src/Builder/Expression/NotOperator.php @@ -22,6 +22,7 @@ class NotOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|ResolvesToBool|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ResolvesToBool|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ObjectToArrayOperator.php b/src/Builder/Expression/ObjectToArrayOperator.php index 1ce5c5c11..67a363a10 100644 --- a/src/Builder/Expression/ObjectToArrayOperator.php +++ b/src/Builder/Expression/ObjectToArrayOperator.php @@ -22,6 +22,7 @@ class ObjectToArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['object' => 'object']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $object Any valid expression as long as it resolves to a document object. $objectToArray applies to the top-level fields of its argument. If the argument is a document that itself contains embedded document fields, the $objectToArray does not recursively apply to the embedded document fields. */ public readonly Document|Serializable|ResolvesToObject|stdClass|array $object; diff --git a/src/Builder/Expression/OrOperator.php b/src/Builder/Expression/OrOperator.php index a34896116..b112c3307 100644 --- a/src/Builder/Expression/OrOperator.php +++ b/src/Builder/Expression/OrOperator.php @@ -25,6 +25,7 @@ class OrOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/PercentileOperator.php b/src/Builder/Expression/PercentileOperator.php index 981719772..3f58d1e37 100644 --- a/src/Builder/Expression/PercentileOperator.php +++ b/src/Builder/Expression/PercentileOperator.php @@ -35,6 +35,7 @@ class PercentileOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'p' => 'p', 'method' => 'method']; /** @var BSONArray|Decimal128|Int64|PackedArray|ResolvesToNumber|array|float|int $input $percentile calculates the percentile values of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $percentile calculation ignores it. */ public readonly Decimal128|Int64|PackedArray|ResolvesToNumber|BSONArray|array|float|int $input; diff --git a/src/Builder/Expression/PowOperator.php b/src/Builder/Expression/PowOperator.php index 1def31e7a..cac6d4caf 100644 --- a/src/Builder/Expression/PowOperator.php +++ b/src/Builder/Expression/PowOperator.php @@ -21,6 +21,7 @@ class PowOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['number' => 'number', 'exponent' => 'exponent']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $number */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $number; diff --git a/src/Builder/Expression/RadiansToDegreesOperator.php b/src/Builder/Expression/RadiansToDegreesOperator.php index 670c26d92..b1c68424f 100644 --- a/src/Builder/Expression/RadiansToDegreesOperator.php +++ b/src/Builder/Expression/RadiansToDegreesOperator.php @@ -21,6 +21,7 @@ class RadiansToDegreesOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $expression; diff --git a/src/Builder/Expression/RangeOperator.php b/src/Builder/Expression/RangeOperator.php index d3d243188..46decaa42 100644 --- a/src/Builder/Expression/RangeOperator.php +++ b/src/Builder/Expression/RangeOperator.php @@ -20,6 +20,7 @@ class RangeOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['start' => 'start', 'end' => 'end', 'step' => 'step']; /** @var ResolvesToInt|int $start An integer that specifies the start of the sequence. Can be any valid expression that resolves to an integer. */ public readonly ResolvesToInt|int $start; diff --git a/src/Builder/Expression/ReduceOperator.php b/src/Builder/Expression/ReduceOperator.php index f57ef2dac..b0849f2ef 100644 --- a/src/Builder/Expression/ReduceOperator.php +++ b/src/Builder/Expression/ReduceOperator.php @@ -28,6 +28,7 @@ class ReduceOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'initialValue' => 'initialValue', 'in' => 'in']; /** * @var BSONArray|PackedArray|ResolvesToArray|array $input Can be any valid expression that resolves to an array. diff --git a/src/Builder/Expression/RegexFindAllOperator.php b/src/Builder/Expression/RegexFindAllOperator.php index e4d2a8d0d..221306d68 100644 --- a/src/Builder/Expression/RegexFindAllOperator.php +++ b/src/Builder/Expression/RegexFindAllOperator.php @@ -22,6 +22,7 @@ class RegexFindAllOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'regex' => 'regex', 'options' => 'options']; /** @var ResolvesToString|string $input The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. */ public readonly ResolvesToString|string $input; diff --git a/src/Builder/Expression/RegexFindOperator.php b/src/Builder/Expression/RegexFindOperator.php index 0b5f30f08..96e7cb368 100644 --- a/src/Builder/Expression/RegexFindOperator.php +++ b/src/Builder/Expression/RegexFindOperator.php @@ -22,6 +22,7 @@ class RegexFindOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'regex' => 'regex', 'options' => 'options']; /** @var ResolvesToString|string $input The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. */ public readonly ResolvesToString|string $input; diff --git a/src/Builder/Expression/RegexMatchOperator.php b/src/Builder/Expression/RegexMatchOperator.php index ed9707b53..6d6c039fc 100644 --- a/src/Builder/Expression/RegexMatchOperator.php +++ b/src/Builder/Expression/RegexMatchOperator.php @@ -22,6 +22,7 @@ class RegexMatchOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'regex' => 'regex', 'options' => 'options']; /** @var ResolvesToString|string $input The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. */ public readonly ResolvesToString|string $input; diff --git a/src/Builder/Expression/ReplaceAllOperator.php b/src/Builder/Expression/ReplaceAllOperator.php index d2fa2a602..60f71fbee 100644 --- a/src/Builder/Expression/ReplaceAllOperator.php +++ b/src/Builder/Expression/ReplaceAllOperator.php @@ -21,6 +21,7 @@ class ReplaceAllOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'find' => 'find', 'replacement' => 'replacement']; /** @var ResolvesToNull|ResolvesToString|null|string $input The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. */ public readonly ResolvesToNull|ResolvesToString|null|string $input; diff --git a/src/Builder/Expression/ReplaceOneOperator.php b/src/Builder/Expression/ReplaceOneOperator.php index 609a0060d..570bd2d72 100644 --- a/src/Builder/Expression/ReplaceOneOperator.php +++ b/src/Builder/Expression/ReplaceOneOperator.php @@ -20,6 +20,7 @@ class ReplaceOneOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'find' => 'find', 'replacement' => 'replacement']; /** @var ResolvesToNull|ResolvesToString|null|string $input The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. */ public readonly ResolvesToNull|ResolvesToString|null|string $input; diff --git a/src/Builder/Expression/ReverseArrayOperator.php b/src/Builder/Expression/ReverseArrayOperator.php index c5bca62b4..ab693e5cd 100644 --- a/src/Builder/Expression/ReverseArrayOperator.php +++ b/src/Builder/Expression/ReverseArrayOperator.php @@ -25,6 +25,7 @@ class ReverseArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression The argument can be any valid expression as long as it resolves to an array. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/RoundOperator.php b/src/Builder/Expression/RoundOperator.php index 323ae99eb..525900b5e 100644 --- a/src/Builder/Expression/RoundOperator.php +++ b/src/Builder/Expression/RoundOperator.php @@ -22,6 +22,7 @@ class RoundOperator implements ResolvesToInt, ResolvesToDouble, ResolvesToDecimal, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['number' => 'number', 'place' => 'place']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $number Can be any valid expression that resolves to a number. Specifically, the expression must resolve to an integer, double, decimal, or long. diff --git a/src/Builder/Expression/RtrimOperator.php b/src/Builder/Expression/RtrimOperator.php index f9a6bc145..13ad7cfea 100644 --- a/src/Builder/Expression/RtrimOperator.php +++ b/src/Builder/Expression/RtrimOperator.php @@ -20,6 +20,7 @@ class RtrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'chars' => 'chars']; /** @var ResolvesToString|string $input The string to trim. The argument can be any valid expression that resolves to a string. */ public readonly ResolvesToString|string $input; diff --git a/src/Builder/Expression/SecondOperator.php b/src/Builder/Expression/SecondOperator.php index 4c9da6db6..a2a676518 100644 --- a/src/Builder/Expression/SecondOperator.php +++ b/src/Builder/Expression/SecondOperator.php @@ -23,6 +23,7 @@ class SecondOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/SetDifferenceOperator.php b/src/Builder/Expression/SetDifferenceOperator.php index ec7e4ff60..58b9ac9f9 100644 --- a/src/Builder/Expression/SetDifferenceOperator.php +++ b/src/Builder/Expression/SetDifferenceOperator.php @@ -25,6 +25,7 @@ class SetDifferenceOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression1 The arguments can be any valid expression as long as they each resolve to an array. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression1; diff --git a/src/Builder/Expression/SetEqualsOperator.php b/src/Builder/Expression/SetEqualsOperator.php index 051da408d..226a818c9 100644 --- a/src/Builder/Expression/SetEqualsOperator.php +++ b/src/Builder/Expression/SetEqualsOperator.php @@ -24,6 +24,7 @@ class SetEqualsOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/SetFieldOperator.php b/src/Builder/Expression/SetFieldOperator.php index f4449ded1..aa527ea2a 100644 --- a/src/Builder/Expression/SetFieldOperator.php +++ b/src/Builder/Expression/SetFieldOperator.php @@ -25,6 +25,7 @@ class SetFieldOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['field' => 'field', 'input' => 'input', 'value' => 'value']; /** @var ResolvesToString|string $field Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. */ public readonly ResolvesToString|string $field; diff --git a/src/Builder/Expression/SetIntersectionOperator.php b/src/Builder/Expression/SetIntersectionOperator.php index 42e3257d6..4f193351b 100644 --- a/src/Builder/Expression/SetIntersectionOperator.php +++ b/src/Builder/Expression/SetIntersectionOperator.php @@ -24,6 +24,7 @@ class SetIntersectionOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/SetIsSubsetOperator.php b/src/Builder/Expression/SetIsSubsetOperator.php index cf2011a0e..77a740e91 100644 --- a/src/Builder/Expression/SetIsSubsetOperator.php +++ b/src/Builder/Expression/SetIsSubsetOperator.php @@ -25,6 +25,7 @@ class SetIsSubsetOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression1 */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression1; diff --git a/src/Builder/Expression/SetUnionOperator.php b/src/Builder/Expression/SetUnionOperator.php index 80080fc5a..2966d324d 100644 --- a/src/Builder/Expression/SetUnionOperator.php +++ b/src/Builder/Expression/SetUnionOperator.php @@ -24,6 +24,7 @@ class SetUnionOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/SinOperator.php b/src/Builder/Expression/SinOperator.php index 1976065f1..e7bea1704 100644 --- a/src/Builder/Expression/SinOperator.php +++ b/src/Builder/Expression/SinOperator.php @@ -21,6 +21,7 @@ class SinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $sin takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. diff --git a/src/Builder/Expression/SinhOperator.php b/src/Builder/Expression/SinhOperator.php index de97f2c8c..f650f3981 100644 --- a/src/Builder/Expression/SinhOperator.php +++ b/src/Builder/Expression/SinhOperator.php @@ -21,6 +21,7 @@ class SinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $sinh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. diff --git a/src/Builder/Expression/SizeOperator.php b/src/Builder/Expression/SizeOperator.php index 5ea541226..aeb312f11 100644 --- a/src/Builder/Expression/SizeOperator.php +++ b/src/Builder/Expression/SizeOperator.php @@ -25,6 +25,7 @@ class SizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression The argument for $size can be any expression as long as it resolves to an array. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/SliceOperator.php b/src/Builder/Expression/SliceOperator.php index df9172133..fc435a51a 100644 --- a/src/Builder/Expression/SliceOperator.php +++ b/src/Builder/Expression/SliceOperator.php @@ -26,6 +26,7 @@ class SliceOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression' => 'expression', 'n' => 'n', 'position' => 'position']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression Any valid expression as long as it resolves to an array. */ public readonly PackedArray|ResolvesToArray|BSONArray|array $expression; diff --git a/src/Builder/Expression/SortArrayOperator.php b/src/Builder/Expression/SortArrayOperator.php index 983408432..8ad43924c 100644 --- a/src/Builder/Expression/SortArrayOperator.php +++ b/src/Builder/Expression/SortArrayOperator.php @@ -29,6 +29,7 @@ class SortArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'sortBy' => 'sortBy']; /** * @var BSONArray|PackedArray|ResolvesToArray|array $input The array to be sorted. diff --git a/src/Builder/Expression/SplitOperator.php b/src/Builder/Expression/SplitOperator.php index 6453cbfe5..60ddf4926 100644 --- a/src/Builder/Expression/SplitOperator.php +++ b/src/Builder/Expression/SplitOperator.php @@ -19,6 +19,7 @@ class SplitOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['string' => 'string', 'delimiter' => 'delimiter']; /** @var ResolvesToString|string $string The string to be split. string expression can be any valid expression as long as it resolves to a string. */ public readonly ResolvesToString|string $string; diff --git a/src/Builder/Expression/SqrtOperator.php b/src/Builder/Expression/SqrtOperator.php index e396c986c..7ac1e20cc 100644 --- a/src/Builder/Expression/SqrtOperator.php +++ b/src/Builder/Expression/SqrtOperator.php @@ -21,6 +21,7 @@ class SqrtOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['number' => 'number']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $number The argument can be any valid expression as long as it resolves to a non-negative number. */ public readonly Decimal128|Int64|ResolvesToNumber|float|int $number; diff --git a/src/Builder/Expression/StdDevPopOperator.php b/src/Builder/Expression/StdDevPopOperator.php index 3845f7a24..181db1946 100644 --- a/src/Builder/Expression/StdDevPopOperator.php +++ b/src/Builder/Expression/StdDevPopOperator.php @@ -26,6 +26,7 @@ class StdDevPopOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/StdDevSampOperator.php b/src/Builder/Expression/StdDevSampOperator.php index 3b6a3c0a7..34cb9cf04 100644 --- a/src/Builder/Expression/StdDevSampOperator.php +++ b/src/Builder/Expression/StdDevSampOperator.php @@ -25,6 +25,7 @@ class StdDevSampOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/StrLenBytesOperator.php b/src/Builder/Expression/StrLenBytesOperator.php index 1f859fce9..33d9794c2 100644 --- a/src/Builder/Expression/StrLenBytesOperator.php +++ b/src/Builder/Expression/StrLenBytesOperator.php @@ -19,6 +19,7 @@ class StrLenBytesOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ public readonly ResolvesToString|string $expression; diff --git a/src/Builder/Expression/StrLenCPOperator.php b/src/Builder/Expression/StrLenCPOperator.php index 7b63f98ff..31334c5ed 100644 --- a/src/Builder/Expression/StrLenCPOperator.php +++ b/src/Builder/Expression/StrLenCPOperator.php @@ -19,6 +19,7 @@ class StrLenCPOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ public readonly ResolvesToString|string $expression; diff --git a/src/Builder/Expression/StrcasecmpOperator.php b/src/Builder/Expression/StrcasecmpOperator.php index ff6f54423..95a3b3118 100644 --- a/src/Builder/Expression/StrcasecmpOperator.php +++ b/src/Builder/Expression/StrcasecmpOperator.php @@ -19,6 +19,7 @@ class StrcasecmpOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ResolvesToString|string $expression1 */ public readonly ResolvesToString|string $expression1; diff --git a/src/Builder/Expression/SubstrBytesOperator.php b/src/Builder/Expression/SubstrBytesOperator.php index 3ff54354c..48c1d1dfe 100644 --- a/src/Builder/Expression/SubstrBytesOperator.php +++ b/src/Builder/Expression/SubstrBytesOperator.php @@ -19,6 +19,7 @@ class SubstrBytesOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; /** @var ResolvesToString|string $string */ public readonly ResolvesToString|string $string; diff --git a/src/Builder/Expression/SubstrCPOperator.php b/src/Builder/Expression/SubstrCPOperator.php index 85baea910..b1e810719 100644 --- a/src/Builder/Expression/SubstrCPOperator.php +++ b/src/Builder/Expression/SubstrCPOperator.php @@ -19,6 +19,7 @@ class SubstrCPOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; /** @var ResolvesToString|string $string */ public readonly ResolvesToString|string $string; diff --git a/src/Builder/Expression/SubstrOperator.php b/src/Builder/Expression/SubstrOperator.php index 9ef174060..0b9b7cfae 100644 --- a/src/Builder/Expression/SubstrOperator.php +++ b/src/Builder/Expression/SubstrOperator.php @@ -19,6 +19,7 @@ class SubstrOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; /** @var ResolvesToString|string $string */ public readonly ResolvesToString|string $string; diff --git a/src/Builder/Expression/SubtractOperator.php b/src/Builder/Expression/SubtractOperator.php index b8cf78387..a734f5a49 100644 --- a/src/Builder/Expression/SubtractOperator.php +++ b/src/Builder/Expression/SubtractOperator.php @@ -22,6 +22,7 @@ class SubtractOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var Decimal128|Int64|ResolvesToDate|ResolvesToNumber|UTCDateTime|float|int $expression1 */ public readonly Decimal128|Int64|UTCDateTime|ResolvesToDate|ResolvesToNumber|float|int $expression1; diff --git a/src/Builder/Expression/SumOperator.php b/src/Builder/Expression/SumOperator.php index dde3535ee..2104cb88e 100644 --- a/src/Builder/Expression/SumOperator.php +++ b/src/Builder/Expression/SumOperator.php @@ -27,6 +27,7 @@ class SumOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ public readonly array $expression; diff --git a/src/Builder/Expression/SwitchOperator.php b/src/Builder/Expression/SwitchOperator.php index 3545477ea..3619919b1 100644 --- a/src/Builder/Expression/SwitchOperator.php +++ b/src/Builder/Expression/SwitchOperator.php @@ -29,6 +29,7 @@ class SwitchOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['branches' => 'branches', 'default' => 'default']; /** * @var BSONArray|PackedArray|array $branches An array of control branch documents. Each branch is a document with the following fields: diff --git a/src/Builder/Expression/TanOperator.php b/src/Builder/Expression/TanOperator.php index 75bc2e00a..e1cc86b9a 100644 --- a/src/Builder/Expression/TanOperator.php +++ b/src/Builder/Expression/TanOperator.php @@ -21,6 +21,7 @@ class TanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $tan takes any valid expression that resolves to a number. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the result to radians. diff --git a/src/Builder/Expression/TanhOperator.php b/src/Builder/Expression/TanhOperator.php index d78a3d42b..111f26ad3 100644 --- a/src/Builder/Expression/TanhOperator.php +++ b/src/Builder/Expression/TanhOperator.php @@ -21,6 +21,7 @@ class TanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $expression $tanh takes any valid expression that resolves to a number, measured in radians. If the expression returns a value in degrees, use the $degreesToRadians operator to convert the value to radians. diff --git a/src/Builder/Expression/ToBoolOperator.php b/src/Builder/Expression/ToBoolOperator.php index 2986fc8d3..90edfe8e7 100644 --- a/src/Builder/Expression/ToBoolOperator.php +++ b/src/Builder/Expression/ToBoolOperator.php @@ -23,6 +23,7 @@ class ToBoolOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToDateOperator.php b/src/Builder/Expression/ToDateOperator.php index d6ff4b2bd..5b91d684f 100644 --- a/src/Builder/Expression/ToDateOperator.php +++ b/src/Builder/Expression/ToDateOperator.php @@ -23,6 +23,7 @@ class ToDateOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToDecimalOperator.php b/src/Builder/Expression/ToDecimalOperator.php index d8dd60379..a36b62426 100644 --- a/src/Builder/Expression/ToDecimalOperator.php +++ b/src/Builder/Expression/ToDecimalOperator.php @@ -23,6 +23,7 @@ class ToDecimalOperator implements ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToDoubleOperator.php b/src/Builder/Expression/ToDoubleOperator.php index a21fe9ad5..ea1e4dba2 100644 --- a/src/Builder/Expression/ToDoubleOperator.php +++ b/src/Builder/Expression/ToDoubleOperator.php @@ -23,6 +23,7 @@ class ToDoubleOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToHashedIndexKeyOperator.php b/src/Builder/Expression/ToHashedIndexKeyOperator.php index e3038832a..ab8bd633f 100644 --- a/src/Builder/Expression/ToHashedIndexKeyOperator.php +++ b/src/Builder/Expression/ToHashedIndexKeyOperator.php @@ -22,6 +22,7 @@ class ToHashedIndexKeyOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $value key or string to hash */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Expression/ToIntOperator.php b/src/Builder/Expression/ToIntOperator.php index d03980572..4a6aaa4d5 100644 --- a/src/Builder/Expression/ToIntOperator.php +++ b/src/Builder/Expression/ToIntOperator.php @@ -23,6 +23,7 @@ class ToIntOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToLongOperator.php b/src/Builder/Expression/ToLongOperator.php index 301113251..73e5d34ec 100644 --- a/src/Builder/Expression/ToLongOperator.php +++ b/src/Builder/Expression/ToLongOperator.php @@ -23,6 +23,7 @@ class ToLongOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToLowerOperator.php b/src/Builder/Expression/ToLowerOperator.php index d680f3296..7496af863 100644 --- a/src/Builder/Expression/ToLowerOperator.php +++ b/src/Builder/Expression/ToLowerOperator.php @@ -19,6 +19,7 @@ class ToLowerOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ public readonly ResolvesToString|string $expression; diff --git a/src/Builder/Expression/ToObjectIdOperator.php b/src/Builder/Expression/ToObjectIdOperator.php index 8e204f67a..2e9e8346e 100644 --- a/src/Builder/Expression/ToObjectIdOperator.php +++ b/src/Builder/Expression/ToObjectIdOperator.php @@ -23,6 +23,7 @@ class ToObjectIdOperator implements ResolvesToObjectId, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToStringOperator.php b/src/Builder/Expression/ToStringOperator.php index c549a6f22..c90cf2d62 100644 --- a/src/Builder/Expression/ToStringOperator.php +++ b/src/Builder/Expression/ToStringOperator.php @@ -23,6 +23,7 @@ class ToStringOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/ToUpperOperator.php b/src/Builder/Expression/ToUpperOperator.php index f57c2cbbf..757afcf23 100644 --- a/src/Builder/Expression/ToUpperOperator.php +++ b/src/Builder/Expression/ToUpperOperator.php @@ -19,6 +19,7 @@ class ToUpperOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ public readonly ResolvesToString|string $expression; diff --git a/src/Builder/Expression/TrimOperator.php b/src/Builder/Expression/TrimOperator.php index def9d3a5a..ffcc89609 100644 --- a/src/Builder/Expression/TrimOperator.php +++ b/src/Builder/Expression/TrimOperator.php @@ -21,6 +21,7 @@ class TrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['input' => 'input', 'chars' => 'chars']; /** @var ResolvesToString|string $input The string to trim. The argument can be any valid expression that resolves to a string. */ public readonly ResolvesToString|string $input; diff --git a/src/Builder/Expression/TruncOperator.php b/src/Builder/Expression/TruncOperator.php index 926d2e11a..fcfa43721 100644 --- a/src/Builder/Expression/TruncOperator.php +++ b/src/Builder/Expression/TruncOperator.php @@ -22,6 +22,7 @@ class TruncOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['number' => 'number', 'place' => 'place']; /** * @var Decimal128|Int64|ResolvesToNumber|float|int $number Can be any valid expression that resolves to a number. Specifically, the expression must resolve to an integer, double, decimal, or long. diff --git a/src/Builder/Expression/TsIncrementOperator.php b/src/Builder/Expression/TsIncrementOperator.php index 3bf5a933a..56aa7bb53 100644 --- a/src/Builder/Expression/TsIncrementOperator.php +++ b/src/Builder/Expression/TsIncrementOperator.php @@ -21,6 +21,7 @@ class TsIncrementOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToTimestamp|Timestamp|int $expression */ public readonly Timestamp|ResolvesToTimestamp|int $expression; diff --git a/src/Builder/Expression/TsSecondOperator.php b/src/Builder/Expression/TsSecondOperator.php index c0dcbe631..7a00cf7fd 100644 --- a/src/Builder/Expression/TsSecondOperator.php +++ b/src/Builder/Expression/TsSecondOperator.php @@ -21,6 +21,7 @@ class TsSecondOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToTimestamp|Timestamp|int $expression */ public readonly Timestamp|ResolvesToTimestamp|int $expression; diff --git a/src/Builder/Expression/TypeOperator.php b/src/Builder/Expression/TypeOperator.php index a65d1dd2e..e43d8d03d 100644 --- a/src/Builder/Expression/TypeOperator.php +++ b/src/Builder/Expression/TypeOperator.php @@ -22,6 +22,7 @@ class TypeOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Expression/UnsetFieldOperator.php b/src/Builder/Expression/UnsetFieldOperator.php index 45e9c41e2..056768ea3 100644 --- a/src/Builder/Expression/UnsetFieldOperator.php +++ b/src/Builder/Expression/UnsetFieldOperator.php @@ -23,6 +23,7 @@ class UnsetFieldOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['field' => 'field', 'input' => 'input']; /** @var ResolvesToString|string $field Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. */ public readonly ResolvesToString|string $field; diff --git a/src/Builder/Expression/WeekOperator.php b/src/Builder/Expression/WeekOperator.php index a24ee935d..701864106 100644 --- a/src/Builder/Expression/WeekOperator.php +++ b/src/Builder/Expression/WeekOperator.php @@ -23,6 +23,7 @@ class WeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/YearOperator.php b/src/Builder/Expression/YearOperator.php index c2b869260..1ecf3f706 100644 --- a/src/Builder/Expression/YearOperator.php +++ b/src/Builder/Expression/YearOperator.php @@ -23,6 +23,7 @@ class YearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; /** @var ObjectId|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|Timestamp|UTCDateTime|int $date The date to which the operator is applied. date must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ public readonly ObjectId|Timestamp|UTCDateTime|ResolvesToDate|ResolvesToObjectId|ResolvesToTimestamp|int $date; diff --git a/src/Builder/Expression/ZipOperator.php b/src/Builder/Expression/ZipOperator.php index 0c23bbd4f..962248a26 100644 --- a/src/Builder/Expression/ZipOperator.php +++ b/src/Builder/Expression/ZipOperator.php @@ -26,6 +26,7 @@ class ZipOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['inputs' => 'inputs', 'useLongestLength' => 'useLongestLength', 'defaults' => 'defaults']; /** * @var BSONArray|PackedArray|ResolvesToArray|array $inputs An array of expressions that resolve to arrays. The elements of these input arrays combine to form the arrays of the output array. diff --git a/src/Builder/Query/AllOperator.php b/src/Builder/Query/AllOperator.php index c4ae5a212..735c4ed04 100644 --- a/src/Builder/Query/AllOperator.php +++ b/src/Builder/Query/AllOperator.php @@ -25,6 +25,7 @@ class AllOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var list $value */ public readonly array $value; diff --git a/src/Builder/Query/AndOperator.php b/src/Builder/Query/AndOperator.php index 40337e870..f9c3bc774 100644 --- a/src/Builder/Query/AndOperator.php +++ b/src/Builder/Query/AndOperator.php @@ -23,6 +23,7 @@ class AndOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['queries' => 'queries']; /** @var list $queries */ public readonly array $queries; diff --git a/src/Builder/Query/BitsAllClearOperator.php b/src/Builder/Query/BitsAllClearOperator.php index 6f056d30b..6590be2bc 100644 --- a/src/Builder/Query/BitsAllClearOperator.php +++ b/src/Builder/Query/BitsAllClearOperator.php @@ -27,6 +27,7 @@ class BitsAllClearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ public readonly Binary|PackedArray|BSONArray|array|int|string $bitmask; diff --git a/src/Builder/Query/BitsAllSetOperator.php b/src/Builder/Query/BitsAllSetOperator.php index 0278b81ee..cc6cf317f 100644 --- a/src/Builder/Query/BitsAllSetOperator.php +++ b/src/Builder/Query/BitsAllSetOperator.php @@ -27,6 +27,7 @@ class BitsAllSetOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ public readonly Binary|PackedArray|BSONArray|array|int|string $bitmask; diff --git a/src/Builder/Query/BitsAnyClearOperator.php b/src/Builder/Query/BitsAnyClearOperator.php index c2b899ea7..47cf5cd6e 100644 --- a/src/Builder/Query/BitsAnyClearOperator.php +++ b/src/Builder/Query/BitsAnyClearOperator.php @@ -27,6 +27,7 @@ class BitsAnyClearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ public readonly Binary|PackedArray|BSONArray|array|int|string $bitmask; diff --git a/src/Builder/Query/BitsAnySetOperator.php b/src/Builder/Query/BitsAnySetOperator.php index 4dcf3c33e..3f5b73550 100644 --- a/src/Builder/Query/BitsAnySetOperator.php +++ b/src/Builder/Query/BitsAnySetOperator.php @@ -27,6 +27,7 @@ class BitsAnySetOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ public readonly Binary|PackedArray|BSONArray|array|int|string $bitmask; diff --git a/src/Builder/Query/BoxOperator.php b/src/Builder/Query/BoxOperator.php index 30a55d1c8..fedcf4b8f 100644 --- a/src/Builder/Query/BoxOperator.php +++ b/src/Builder/Query/BoxOperator.php @@ -26,6 +26,7 @@ class BoxOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ public readonly PackedArray|BSONArray|array $value; diff --git a/src/Builder/Query/CenterOperator.php b/src/Builder/Query/CenterOperator.php index d5bc395f0..c19a19812 100644 --- a/src/Builder/Query/CenterOperator.php +++ b/src/Builder/Query/CenterOperator.php @@ -26,6 +26,7 @@ class CenterOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ public readonly PackedArray|BSONArray|array $value; diff --git a/src/Builder/Query/CenterSphereOperator.php b/src/Builder/Query/CenterSphereOperator.php index 0975417a9..56dd2ab33 100644 --- a/src/Builder/Query/CenterSphereOperator.php +++ b/src/Builder/Query/CenterSphereOperator.php @@ -26,6 +26,7 @@ class CenterSphereOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ public readonly PackedArray|BSONArray|array $value; diff --git a/src/Builder/Query/CommentOperator.php b/src/Builder/Query/CommentOperator.php index 121c0e3b6..6292ec307 100644 --- a/src/Builder/Query/CommentOperator.php +++ b/src/Builder/Query/CommentOperator.php @@ -20,6 +20,7 @@ class CommentOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['comment' => 'comment']; /** @var string $comment */ public readonly string $comment; diff --git a/src/Builder/Query/ElemMatchOperator.php b/src/Builder/Query/ElemMatchOperator.php index 073619874..7a1edcf3f 100644 --- a/src/Builder/Query/ElemMatchOperator.php +++ b/src/Builder/Query/ElemMatchOperator.php @@ -26,6 +26,7 @@ class ElemMatchOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['query' => 'query']; /** @var FieldQueryInterface|QueryInterface|Type|array|bool|float|int|null|stdClass|string $query */ public readonly Type|FieldQueryInterface|QueryInterface|stdClass|array|bool|float|int|null|string $query; diff --git a/src/Builder/Query/EqOperator.php b/src/Builder/Query/EqOperator.php index 2dcd605fd..6bacfe6a7 100644 --- a/src/Builder/Query/EqOperator.php +++ b/src/Builder/Query/EqOperator.php @@ -22,6 +22,7 @@ class EqOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Query/ExistsOperator.php b/src/Builder/Query/ExistsOperator.php index 92c04f066..80f078124 100644 --- a/src/Builder/Query/ExistsOperator.php +++ b/src/Builder/Query/ExistsOperator.php @@ -20,6 +20,7 @@ class ExistsOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['exists' => 'exists']; /** @var bool $exists */ public readonly bool $exists; diff --git a/src/Builder/Query/ExprOperator.php b/src/Builder/Query/ExprOperator.php index a6235cb67..5ab3aa482 100644 --- a/src/Builder/Query/ExprOperator.php +++ b/src/Builder/Query/ExprOperator.php @@ -23,6 +23,7 @@ class ExprOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Query/GeoIntersectsOperator.php b/src/Builder/Query/GeoIntersectsOperator.php index 2ae07a182..0c9bd760c 100644 --- a/src/Builder/Query/GeoIntersectsOperator.php +++ b/src/Builder/Query/GeoIntersectsOperator.php @@ -23,7 +23,8 @@ */ class GeoIntersectsOperator implements FieldQueryInterface, OperatorInterface { - public const ENCODE = Encode::Single; + public const ENCODE = Encode::Object; + public const PROPERTIES = ['geometry' => null]; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ public readonly Document|Serializable|GeometryInterface|stdClass|array $geometry; diff --git a/src/Builder/Query/GeoWithinOperator.php b/src/Builder/Query/GeoWithinOperator.php index 939e13d4a..0dfb751dd 100644 --- a/src/Builder/Query/GeoWithinOperator.php +++ b/src/Builder/Query/GeoWithinOperator.php @@ -23,7 +23,8 @@ */ class GeoWithinOperator implements FieldQueryInterface, OperatorInterface { - public const ENCODE = Encode::Single; + public const ENCODE = Encode::Object; + public const PROPERTIES = ['geometry' => null]; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ public readonly Document|Serializable|GeometryInterface|stdClass|array $geometry; diff --git a/src/Builder/Query/GeometryOperator.php b/src/Builder/Query/GeometryOperator.php index efdd38a1f..936b8a1a8 100644 --- a/src/Builder/Query/GeometryOperator.php +++ b/src/Builder/Query/GeometryOperator.php @@ -30,6 +30,7 @@ class GeometryOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['type' => 'type', 'coordinates' => 'coordinates', 'crs' => 'crs']; /** @var string $type */ public readonly string $type; diff --git a/src/Builder/Query/GtOperator.php b/src/Builder/Query/GtOperator.php index 31c03e485..e651d72e6 100644 --- a/src/Builder/Query/GtOperator.php +++ b/src/Builder/Query/GtOperator.php @@ -22,6 +22,7 @@ class GtOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Query/GteOperator.php b/src/Builder/Query/GteOperator.php index 2ef771f1d..1b4dbd054 100644 --- a/src/Builder/Query/GteOperator.php +++ b/src/Builder/Query/GteOperator.php @@ -22,6 +22,7 @@ class GteOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Query/InOperator.php b/src/Builder/Query/InOperator.php index 605a90b92..4568667d0 100644 --- a/src/Builder/Query/InOperator.php +++ b/src/Builder/Query/InOperator.php @@ -26,6 +26,7 @@ class InOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ public readonly PackedArray|BSONArray|array $value; diff --git a/src/Builder/Query/JsonSchemaOperator.php b/src/Builder/Query/JsonSchemaOperator.php index cce8438be..869247f2e 100644 --- a/src/Builder/Query/JsonSchemaOperator.php +++ b/src/Builder/Query/JsonSchemaOperator.php @@ -23,6 +23,7 @@ class JsonSchemaOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['schema' => 'schema']; /** @var Document|Serializable|array|stdClass $schema */ public readonly Document|Serializable|stdClass|array $schema; diff --git a/src/Builder/Query/LtOperator.php b/src/Builder/Query/LtOperator.php index f29c73b57..dcfebce40 100644 --- a/src/Builder/Query/LtOperator.php +++ b/src/Builder/Query/LtOperator.php @@ -22,6 +22,7 @@ class LtOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Query/LteOperator.php b/src/Builder/Query/LteOperator.php index 18453cb58..cb260c8d7 100644 --- a/src/Builder/Query/LteOperator.php +++ b/src/Builder/Query/LteOperator.php @@ -22,6 +22,7 @@ class LteOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Query/MaxDistanceOperator.php b/src/Builder/Query/MaxDistanceOperator.php index 864f1b60f..92b3129da 100644 --- a/src/Builder/Query/MaxDistanceOperator.php +++ b/src/Builder/Query/MaxDistanceOperator.php @@ -22,6 +22,7 @@ class MaxDistanceOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Decimal128|Int64|float|int $value */ public readonly Decimal128|Int64|float|int $value; diff --git a/src/Builder/Query/MinDistanceOperator.php b/src/Builder/Query/MinDistanceOperator.php index ea57b8e3b..cdd97fe32 100644 --- a/src/Builder/Query/MinDistanceOperator.php +++ b/src/Builder/Query/MinDistanceOperator.php @@ -21,6 +21,7 @@ class MinDistanceOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Int64|float|int $value */ public readonly Int64|float|int $value; diff --git a/src/Builder/Query/ModOperator.php b/src/Builder/Query/ModOperator.php index e608bf9c9..749785387 100644 --- a/src/Builder/Query/ModOperator.php +++ b/src/Builder/Query/ModOperator.php @@ -22,6 +22,7 @@ class ModOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Array; + public const PROPERTIES = ['divisor' => 'divisor', 'remainder' => 'remainder']; /** @var Decimal128|Int64|float|int $divisor */ public readonly Decimal128|Int64|float|int $divisor; diff --git a/src/Builder/Query/NeOperator.php b/src/Builder/Query/NeOperator.php index 9c12c851c..de2f35bb5 100644 --- a/src/Builder/Query/NeOperator.php +++ b/src/Builder/Query/NeOperator.php @@ -22,6 +22,7 @@ class NeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ public readonly Type|stdClass|array|bool|float|int|null|string $value; diff --git a/src/Builder/Query/NearOperator.php b/src/Builder/Query/NearOperator.php index 68b99aa5e..ec59bbfdf 100644 --- a/src/Builder/Query/NearOperator.php +++ b/src/Builder/Query/NearOperator.php @@ -26,7 +26,8 @@ */ class NearOperator implements FieldQueryInterface, OperatorInterface { - public const ENCODE = Encode::DollarObject; + public const ENCODE = Encode::Object; + public const PROPERTIES = ['geometry' => null, 'maxDistance' => '$maxDistance', 'minDistance' => '$minDistance']; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ public readonly Document|Serializable|GeometryInterface|stdClass|array $geometry; diff --git a/src/Builder/Query/NearSphereOperator.php b/src/Builder/Query/NearSphereOperator.php index aab04903d..502f18db8 100644 --- a/src/Builder/Query/NearSphereOperator.php +++ b/src/Builder/Query/NearSphereOperator.php @@ -26,7 +26,8 @@ */ class NearSphereOperator implements FieldQueryInterface, OperatorInterface { - public const ENCODE = Encode::DollarObject; + public const ENCODE = Encode::Object; + public const PROPERTIES = ['geometry' => null, 'maxDistance' => '$maxDistance', 'minDistance' => '$minDistance']; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ public readonly Document|Serializable|GeometryInterface|stdClass|array $geometry; diff --git a/src/Builder/Query/NinOperator.php b/src/Builder/Query/NinOperator.php index 8b348b733..64550e59d 100644 --- a/src/Builder/Query/NinOperator.php +++ b/src/Builder/Query/NinOperator.php @@ -26,6 +26,7 @@ class NinOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ public readonly PackedArray|BSONArray|array $value; diff --git a/src/Builder/Query/NorOperator.php b/src/Builder/Query/NorOperator.php index 4ff7f41a4..71c134170 100644 --- a/src/Builder/Query/NorOperator.php +++ b/src/Builder/Query/NorOperator.php @@ -23,6 +23,7 @@ class NorOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['queries' => 'queries']; /** @var list $queries */ public readonly array $queries; diff --git a/src/Builder/Query/NotOperator.php b/src/Builder/Query/NotOperator.php index c6d135445..b4ee6f9c6 100644 --- a/src/Builder/Query/NotOperator.php +++ b/src/Builder/Query/NotOperator.php @@ -22,6 +22,7 @@ class NotOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var FieldQueryInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|FieldQueryInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Query/OrOperator.php b/src/Builder/Query/OrOperator.php index f7ae64279..eeb7a4fe3 100644 --- a/src/Builder/Query/OrOperator.php +++ b/src/Builder/Query/OrOperator.php @@ -23,6 +23,7 @@ class OrOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['queries' => 'queries']; /** @var list $queries */ public readonly array $queries; diff --git a/src/Builder/Query/PolygonOperator.php b/src/Builder/Query/PolygonOperator.php index 6c829e076..7337e2be5 100644 --- a/src/Builder/Query/PolygonOperator.php +++ b/src/Builder/Query/PolygonOperator.php @@ -26,6 +26,7 @@ class PolygonOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['points' => 'points']; /** @var BSONArray|PackedArray|array $points */ public readonly PackedArray|BSONArray|array $points; diff --git a/src/Builder/Query/RegexOperator.php b/src/Builder/Query/RegexOperator.php index 48c9788e8..661858925 100644 --- a/src/Builder/Query/RegexOperator.php +++ b/src/Builder/Query/RegexOperator.php @@ -21,6 +21,7 @@ class RegexOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['regex' => 'regex']; /** @var Regex $regex */ public readonly Regex $regex; diff --git a/src/Builder/Query/SampleRateOperator.php b/src/Builder/Query/SampleRateOperator.php index a21a1ba5a..cd98624e8 100644 --- a/src/Builder/Query/SampleRateOperator.php +++ b/src/Builder/Query/SampleRateOperator.php @@ -22,6 +22,7 @@ class SampleRateOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['rate' => 'rate']; /** * @var Int64|ResolvesToDouble|float|int $rate The selection process uses a uniform random distribution. The sample rate is a floating point number between 0 and 1, inclusive, which represents the probability that a given document will be selected as it passes through the pipeline. diff --git a/src/Builder/Query/SizeOperator.php b/src/Builder/Query/SizeOperator.php index db9176c82..dae052ca1 100644 --- a/src/Builder/Query/SizeOperator.php +++ b/src/Builder/Query/SizeOperator.php @@ -20,6 +20,7 @@ class SizeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['value' => 'value']; /** @var int $value */ public readonly int $value; diff --git a/src/Builder/Query/TextOperator.php b/src/Builder/Query/TextOperator.php index 47b88ede1..343af3248 100644 --- a/src/Builder/Query/TextOperator.php +++ b/src/Builder/Query/TextOperator.php @@ -20,7 +20,14 @@ */ class TextOperator implements QueryInterface, OperatorInterface { - public const ENCODE = Encode::DollarObject; + public const ENCODE = Encode::Object; + + public const PROPERTIES = [ + 'search' => '$search', + 'language' => '$language', + 'caseSensitive' => '$caseSensitive', + 'diacriticSensitive' => '$diacriticSensitive', + ]; /** @var string $search A string of terms that MongoDB parses and uses to query the text index. MongoDB performs a logical OR search of the terms unless specified as a phrase. */ public readonly string $search; diff --git a/src/Builder/Query/TypeOperator.php b/src/Builder/Query/TypeOperator.php index cffe79092..f06442c7b 100644 --- a/src/Builder/Query/TypeOperator.php +++ b/src/Builder/Query/TypeOperator.php @@ -23,6 +23,7 @@ class TypeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['type' => 'type']; /** @var list $type */ public readonly array $type; diff --git a/src/Builder/Query/WhereOperator.php b/src/Builder/Query/WhereOperator.php index 5a38eb8c6..87e7caf50 100644 --- a/src/Builder/Query/WhereOperator.php +++ b/src/Builder/Query/WhereOperator.php @@ -23,6 +23,7 @@ class WhereOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['function' => 'function']; /** @var Javascript|string $function */ public readonly Javascript|string $function; diff --git a/src/Builder/Stage/AddFieldsStage.php b/src/Builder/Stage/AddFieldsStage.php index 15f509264..12edbc754 100644 --- a/src/Builder/Stage/AddFieldsStage.php +++ b/src/Builder/Stage/AddFieldsStage.php @@ -26,6 +26,7 @@ class AddFieldsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var stdClass $expression Specify the name of each field to add and set its value to an aggregation expression or an empty object. */ public readonly stdClass $expression; diff --git a/src/Builder/Stage/BucketAutoStage.php b/src/Builder/Stage/BucketAutoStage.php index 341421f44..6c08506c9 100644 --- a/src/Builder/Stage/BucketAutoStage.php +++ b/src/Builder/Stage/BucketAutoStage.php @@ -27,6 +27,13 @@ class BucketAutoStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'groupBy' => 'groupBy', + 'buckets' => 'buckets', + 'output' => 'output', + 'granularity' => 'granularity', + ]; + /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $groupBy An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes. */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $groupBy; diff --git a/src/Builder/Stage/BucketStage.php b/src/Builder/Stage/BucketStage.php index 47a497153..2fcd15693 100644 --- a/src/Builder/Stage/BucketStage.php +++ b/src/Builder/Stage/BucketStage.php @@ -33,6 +33,13 @@ class BucketStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'groupBy' => 'groupBy', + 'boundaries' => 'boundaries', + 'default' => 'default', + 'output' => 'output', + ]; + /** * @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $groupBy An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes. * Unless $bucket includes a default specification, each input document must resolve the groupBy field path or expression to a value that falls within one of the ranges specified by the boundaries. diff --git a/src/Builder/Stage/ChangeStreamStage.php b/src/Builder/Stage/ChangeStreamStage.php index 184ae96ee..d75103e31 100644 --- a/src/Builder/Stage/ChangeStreamStage.php +++ b/src/Builder/Stage/ChangeStreamStage.php @@ -26,6 +26,16 @@ class ChangeStreamStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'allChangesForCluster' => 'allChangesForCluster', + 'fullDocument' => 'fullDocument', + 'fullDocumentBeforeChange' => 'fullDocumentBeforeChange', + 'resumeAfter' => 'resumeAfter', + 'showExpandedEvents' => 'showExpandedEvents', + 'startAfter' => 'startAfter', + 'startAtOperationTime' => 'startAtOperationTime', + ]; + /** @var Optional|bool $allChangesForCluster A flag indicating whether the stream should report all changes that occur on the deployment, aside from those on internal databases or collections. */ public readonly Optional|bool $allChangesForCluster; diff --git a/src/Builder/Stage/CollStatsStage.php b/src/Builder/Stage/CollStatsStage.php index 96f048f46..d32ae5883 100644 --- a/src/Builder/Stage/CollStatsStage.php +++ b/src/Builder/Stage/CollStatsStage.php @@ -25,6 +25,13 @@ class CollStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'latencyStats' => 'latencyStats', + 'storageStats' => 'storageStats', + 'count' => 'count', + 'queryExecStats' => 'queryExecStats', + ]; + /** @var Optional|Document|Serializable|array|stdClass $latencyStats */ public readonly Optional|Document|Serializable|stdClass|array $latencyStats; diff --git a/src/Builder/Stage/CountStage.php b/src/Builder/Stage/CountStage.php index 3864f00c5..93dd8eeb6 100644 --- a/src/Builder/Stage/CountStage.php +++ b/src/Builder/Stage/CountStage.php @@ -21,6 +21,7 @@ class CountStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['field' => 'field']; /** @var string $field Name of the output field which has the count as its value. It must be a non-empty string, must not start with $ and must not contain the . character. */ public readonly string $field; diff --git a/src/Builder/Stage/CurrentOpStage.php b/src/Builder/Stage/CurrentOpStage.php index 3b5930d32..78413d2a8 100644 --- a/src/Builder/Stage/CurrentOpStage.php +++ b/src/Builder/Stage/CurrentOpStage.php @@ -22,6 +22,14 @@ class CurrentOpStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'allUsers' => 'allUsers', + 'idleConnections' => 'idleConnections', + 'idleCursors' => 'idleCursors', + 'idleSessions' => 'idleSessions', + 'localOps' => 'localOps', + ]; + /** @var Optional|bool $allUsers */ public readonly Optional|bool $allUsers; diff --git a/src/Builder/Stage/DensifyStage.php b/src/Builder/Stage/DensifyStage.php index 3abfcb3fe..953bf8b13 100644 --- a/src/Builder/Stage/DensifyStage.php +++ b/src/Builder/Stage/DensifyStage.php @@ -30,6 +30,7 @@ class DensifyStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['field' => 'field', 'range' => 'range', 'partitionByFields' => 'partitionByFields']; /** * @var string $field The field to densify. The values of the specified field must either be all numeric values or all dates. diff --git a/src/Builder/Stage/DocumentsStage.php b/src/Builder/Stage/DocumentsStage.php index 1ca0a3f9c..7a7b0a82d 100644 --- a/src/Builder/Stage/DocumentsStage.php +++ b/src/Builder/Stage/DocumentsStage.php @@ -27,6 +27,7 @@ class DocumentsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['documents' => 'documents']; /** * @var BSONArray|PackedArray|ResolvesToArray|array $documents $documents accepts any valid expression that resolves to an array of objects. This includes: diff --git a/src/Builder/Stage/FacetStage.php b/src/Builder/Stage/FacetStage.php index e334167bf..1a6066f71 100644 --- a/src/Builder/Stage/FacetStage.php +++ b/src/Builder/Stage/FacetStage.php @@ -27,6 +27,7 @@ class FacetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['facet' => 'facet']; /** @var stdClass $facet */ public readonly stdClass $facet; diff --git a/src/Builder/Stage/FillStage.php b/src/Builder/Stage/FillStage.php index 634c05b8d..f5eac51e1 100644 --- a/src/Builder/Stage/FillStage.php +++ b/src/Builder/Stage/FillStage.php @@ -31,6 +31,13 @@ class FillStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'output' => 'output', + 'partitionBy' => 'partitionBy', + 'partitionByFields' => 'partitionByFields', + 'sortBy' => 'sortBy', + ]; + /** * @var Document|Serializable|array|stdClass $output Specifies an object containing each field for which to fill missing values. You can specify multiple fields in the output object. * The object name is the name of the field to fill. The object value specifies how the field is filled. diff --git a/src/Builder/Stage/GeoNearStage.php b/src/Builder/Stage/GeoNearStage.php index d39766dc5..3864d5f43 100644 --- a/src/Builder/Stage/GeoNearStage.php +++ b/src/Builder/Stage/GeoNearStage.php @@ -32,6 +32,18 @@ class GeoNearStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'distanceField' => 'distanceField', + 'near' => 'near', + 'distanceMultiplier' => 'distanceMultiplier', + 'includeLocs' => 'includeLocs', + 'key' => 'key', + 'maxDistance' => 'maxDistance', + 'minDistance' => 'minDistance', + 'query' => 'query', + 'spherical' => 'spherical', + ]; + /** @var string $distanceField The output field that contains the calculated distance. To specify a field within an embedded document, use dot notation. */ public readonly string $distanceField; diff --git a/src/Builder/Stage/GraphLookupStage.php b/src/Builder/Stage/GraphLookupStage.php index ceaa7a4b1..7809e146f 100644 --- a/src/Builder/Stage/GraphLookupStage.php +++ b/src/Builder/Stage/GraphLookupStage.php @@ -33,6 +33,17 @@ class GraphLookupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'from' => 'from', + 'startWith' => 'startWith', + 'connectFromField' => 'connectFromField', + 'connectToField' => 'connectToField', + 'as' => 'as', + 'maxDepth' => 'maxDepth', + 'depthField' => 'depthField', + 'restrictSearchWithMatch' => 'restrictSearchWithMatch', + ]; + /** * @var string $from Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField. The from collection must be in the same database as any other collections used in the operation. * Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. diff --git a/src/Builder/Stage/GroupStage.php b/src/Builder/Stage/GroupStage.php index a16038007..ea0c8b4b4 100644 --- a/src/Builder/Stage/GroupStage.php +++ b/src/Builder/Stage/GroupStage.php @@ -28,7 +28,8 @@ */ class GroupStage implements StageInterface, OperatorInterface { - public const ENCODE = Encode::Group; + public const ENCODE = Encode::Object; + public const PROPERTIES = ['_id' => '_id', 'field' => null]; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $_id The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents. */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $_id; diff --git a/src/Builder/Stage/LimitStage.php b/src/Builder/Stage/LimitStage.php index 593fc2c70..af3052de6 100644 --- a/src/Builder/Stage/LimitStage.php +++ b/src/Builder/Stage/LimitStage.php @@ -20,6 +20,7 @@ class LimitStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['limit' => 'limit']; /** @var int $limit */ public readonly int $limit; diff --git a/src/Builder/Stage/ListLocalSessionsStage.php b/src/Builder/Stage/ListLocalSessionsStage.php index de60e49f4..bb6c8e236 100644 --- a/src/Builder/Stage/ListLocalSessionsStage.php +++ b/src/Builder/Stage/ListLocalSessionsStage.php @@ -27,6 +27,7 @@ class ListLocalSessionsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['users' => 'users', 'allUsers' => 'allUsers']; /** @var Optional|BSONArray|PackedArray|array $users Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. */ public readonly Optional|PackedArray|BSONArray|array $users; diff --git a/src/Builder/Stage/ListSampledQueriesStage.php b/src/Builder/Stage/ListSampledQueriesStage.php index 8669c0fe8..a45a614c5 100644 --- a/src/Builder/Stage/ListSampledQueriesStage.php +++ b/src/Builder/Stage/ListSampledQueriesStage.php @@ -21,6 +21,7 @@ class ListSampledQueriesStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['namespace' => 'namespace']; /** @var Optional|string $namespace */ public readonly Optional|string $namespace; diff --git a/src/Builder/Stage/ListSearchIndexesStage.php b/src/Builder/Stage/ListSearchIndexesStage.php index a2850eab2..ec4b044ac 100644 --- a/src/Builder/Stage/ListSearchIndexesStage.php +++ b/src/Builder/Stage/ListSearchIndexesStage.php @@ -21,6 +21,7 @@ class ListSearchIndexesStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['id' => 'id', 'name' => 'name']; /** @var Optional|string $id The id of the index to return information about. */ public readonly Optional|string $id; diff --git a/src/Builder/Stage/ListSessionsStage.php b/src/Builder/Stage/ListSessionsStage.php index f299874db..96bbe4ebd 100644 --- a/src/Builder/Stage/ListSessionsStage.php +++ b/src/Builder/Stage/ListSessionsStage.php @@ -27,6 +27,7 @@ class ListSessionsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['users' => 'users', 'allUsers' => 'allUsers']; /** @var Optional|BSONArray|PackedArray|array $users Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. */ public readonly Optional|PackedArray|BSONArray|array $users; diff --git a/src/Builder/Stage/LookupStage.php b/src/Builder/Stage/LookupStage.php index 34f0fb66f..a42166468 100644 --- a/src/Builder/Stage/LookupStage.php +++ b/src/Builder/Stage/LookupStage.php @@ -32,6 +32,15 @@ class LookupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'as' => 'as', + 'from' => 'from', + 'localField' => 'localField', + 'foreignField' => 'foreignField', + 'let' => 'let', + 'pipeline' => 'pipeline', + ]; + /** @var string $as Specifies the name of the new array field to add to the input documents. The new array field contains the matching documents from the from collection. If the specified name already exists in the input document, the existing field is overwritten. */ public readonly string $as; diff --git a/src/Builder/Stage/MatchStage.php b/src/Builder/Stage/MatchStage.php index 9590763ae..36c827831 100644 --- a/src/Builder/Stage/MatchStage.php +++ b/src/Builder/Stage/MatchStage.php @@ -24,6 +24,7 @@ class MatchStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['query' => 'query']; /** @var QueryInterface|array $query */ public readonly QueryInterface|array $query; diff --git a/src/Builder/Stage/MergeStage.php b/src/Builder/Stage/MergeStage.php index 271c012ac..6d00416c2 100644 --- a/src/Builder/Stage/MergeStage.php +++ b/src/Builder/Stage/MergeStage.php @@ -33,6 +33,14 @@ class MergeStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'into' => 'into', + 'on' => 'on', + 'let' => 'let', + 'whenMatched' => 'whenMatched', + 'whenNotMatched' => 'whenNotMatched', + ]; + /** @var Document|Serializable|array|stdClass|string $into The output collection. */ public readonly Document|Serializable|stdClass|array|string $into; diff --git a/src/Builder/Stage/OutStage.php b/src/Builder/Stage/OutStage.php index 5e99d578a..7bad49b83 100644 --- a/src/Builder/Stage/OutStage.php +++ b/src/Builder/Stage/OutStage.php @@ -23,6 +23,7 @@ class OutStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['coll' => 'coll']; /** @var Document|Serializable|array|stdClass|string $coll Target database name to write documents from $out to. */ public readonly Document|Serializable|stdClass|array|string $coll; diff --git a/src/Builder/Stage/ProjectStage.php b/src/Builder/Stage/ProjectStage.php index c8cd58c04..0a9944900 100644 --- a/src/Builder/Stage/ProjectStage.php +++ b/src/Builder/Stage/ProjectStage.php @@ -26,6 +26,7 @@ class ProjectStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['specification' => 'specification']; /** @var stdClass $specification */ public readonly stdClass $specification; diff --git a/src/Builder/Stage/RedactStage.php b/src/Builder/Stage/RedactStage.php index 96dcab949..d6bb6a33d 100644 --- a/src/Builder/Stage/RedactStage.php +++ b/src/Builder/Stage/RedactStage.php @@ -23,6 +23,7 @@ class RedactStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Stage/ReplaceRootStage.php b/src/Builder/Stage/ReplaceRootStage.php index 5c97b1f15..abf5ef38b 100644 --- a/src/Builder/Stage/ReplaceRootStage.php +++ b/src/Builder/Stage/ReplaceRootStage.php @@ -24,6 +24,7 @@ class ReplaceRootStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['newRoot' => 'newRoot']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $newRoot */ public readonly Document|Serializable|ResolvesToObject|stdClass|array $newRoot; diff --git a/src/Builder/Stage/ReplaceWithStage.php b/src/Builder/Stage/ReplaceWithStage.php index 6741a38fc..72bb85cb2 100644 --- a/src/Builder/Stage/ReplaceWithStage.php +++ b/src/Builder/Stage/ReplaceWithStage.php @@ -25,6 +25,7 @@ class ReplaceWithStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $expression */ public readonly Document|Serializable|ResolvesToObject|stdClass|array $expression; diff --git a/src/Builder/Stage/SampleStage.php b/src/Builder/Stage/SampleStage.php index 9cf433eb5..8ac8a9f4f 100644 --- a/src/Builder/Stage/SampleStage.php +++ b/src/Builder/Stage/SampleStage.php @@ -20,6 +20,7 @@ class SampleStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['size' => 'size']; /** @var int $size The number of documents to randomly select. */ public readonly int $size; diff --git a/src/Builder/Stage/SearchMetaStage.php b/src/Builder/Stage/SearchMetaStage.php index c27b230eb..7f40dff57 100644 --- a/src/Builder/Stage/SearchMetaStage.php +++ b/src/Builder/Stage/SearchMetaStage.php @@ -24,6 +24,7 @@ class SearchMetaStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['meta' => 'meta']; /** @var Document|Serializable|array|stdClass $meta */ public readonly Document|Serializable|stdClass|array $meta; diff --git a/src/Builder/Stage/SearchStage.php b/src/Builder/Stage/SearchStage.php index 3eed9c17d..7f51b7e56 100644 --- a/src/Builder/Stage/SearchStage.php +++ b/src/Builder/Stage/SearchStage.php @@ -24,6 +24,7 @@ class SearchStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['search' => 'search']; /** @var Document|Serializable|array|stdClass $search */ public readonly Document|Serializable|stdClass|array $search; diff --git a/src/Builder/Stage/SetStage.php b/src/Builder/Stage/SetStage.php index ca929a2b8..01c6722f8 100644 --- a/src/Builder/Stage/SetStage.php +++ b/src/Builder/Stage/SetStage.php @@ -27,6 +27,7 @@ class SetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['field' => 'field']; /** @var stdClass $field */ public readonly stdClass $field; diff --git a/src/Builder/Stage/SetWindowFieldsStage.php b/src/Builder/Stage/SetWindowFieldsStage.php index cb1354e66..19fff4059 100644 --- a/src/Builder/Stage/SetWindowFieldsStage.php +++ b/src/Builder/Stage/SetWindowFieldsStage.php @@ -27,6 +27,7 @@ class SetWindowFieldsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output', 'partitionBy' => 'partitionBy']; /** @var Document|Serializable|array|stdClass $sortBy Specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting. */ public readonly Document|Serializable|stdClass|array $sortBy; diff --git a/src/Builder/Stage/SkipStage.php b/src/Builder/Stage/SkipStage.php index 171ee515a..c6e8e9746 100644 --- a/src/Builder/Stage/SkipStage.php +++ b/src/Builder/Stage/SkipStage.php @@ -20,6 +20,7 @@ class SkipStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['skip' => 'skip']; /** @var int $skip */ public readonly int $skip; diff --git a/src/Builder/Stage/SortByCountStage.php b/src/Builder/Stage/SortByCountStage.php index 9c7160b8c..0e22051ab 100644 --- a/src/Builder/Stage/SortByCountStage.php +++ b/src/Builder/Stage/SortByCountStage.php @@ -23,6 +23,7 @@ class SortByCountStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ public readonly Type|ExpressionInterface|stdClass|array|bool|float|int|null|string $expression; diff --git a/src/Builder/Stage/SortStage.php b/src/Builder/Stage/SortStage.php index 5f4de9e19..a707c41e8 100644 --- a/src/Builder/Stage/SortStage.php +++ b/src/Builder/Stage/SortStage.php @@ -27,6 +27,7 @@ class SortStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['sort' => 'sort']; /** @var stdClass $sort */ public readonly stdClass $sort; diff --git a/src/Builder/Stage/UnionWithStage.php b/src/Builder/Stage/UnionWithStage.php index 0882f74cb..c3ac7c068 100644 --- a/src/Builder/Stage/UnionWithStage.php +++ b/src/Builder/Stage/UnionWithStage.php @@ -29,6 +29,7 @@ class UnionWithStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = ['coll' => 'coll', 'pipeline' => 'pipeline']; /** @var string $coll The collection or view whose pipeline results you wish to include in the result set. */ public readonly string $coll; diff --git a/src/Builder/Stage/UnsetStage.php b/src/Builder/Stage/UnsetStage.php index f75546ed0..bdf754d88 100644 --- a/src/Builder/Stage/UnsetStage.php +++ b/src/Builder/Stage/UnsetStage.php @@ -25,6 +25,7 @@ class UnsetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const PROPERTIES = ['field' => 'field']; /** @var list $field */ public readonly array $field; diff --git a/src/Builder/Stage/UnwindStage.php b/src/Builder/Stage/UnwindStage.php index 09c9f1e82..39777e109 100644 --- a/src/Builder/Stage/UnwindStage.php +++ b/src/Builder/Stage/UnwindStage.php @@ -23,6 +23,12 @@ class UnwindStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const PROPERTIES = [ + 'path' => 'path', + 'includeArrayIndex' => 'includeArrayIndex', + 'preserveNullAndEmptyArrays' => 'preserveNullAndEmptyArrays', + ]; + /** @var ArrayFieldPath|string $path Field path to an array field. */ public readonly ArrayFieldPath|string $path; diff --git a/src/Builder/Type/Encode.php b/src/Builder/Type/Encode.php index 85a5eaf66..a4dcfa7e3 100644 --- a/src/Builder/Type/Encode.php +++ b/src/Builder/Type/Encode.php @@ -28,21 +28,11 @@ enum Encode */ case FlatObject; - /** - * Parameters are encoded as an object with keys matching the parameter names prefixed with a dollar sign ($) - */ - case DollarObject; - /** * Get the single parameter value */ case Single; - /** - * Specific for $group stage - */ - case Group; - /** * Default case used in the interface; implementing classes are expected to override this value */ diff --git a/src/Builder/Type/OperatorInterface.php b/src/Builder/Type/OperatorInterface.php index f219fb52b..52b1aaa9b 100644 --- a/src/Builder/Type/OperatorInterface.php +++ b/src/Builder/Type/OperatorInterface.php @@ -9,8 +9,11 @@ */ interface OperatorInterface { - /** To be overridden by implementing classes */ + /** @var Encode */ public const ENCODE = Encode::Undefined; + /** @var array */ + public const PROPERTIES = []; + public function getOperator(): string; }