From f9400d98315f3ddd4e6d95da76cefafdd9d2be05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 2 Dec 2024 21:16:54 +0100 Subject: [PATCH 1/5] Remove unused Projection operator (#1543) --- .gitattributes | 1 - psalm-baseline.xml | 5 --- src/Builder/Projection.php | 22 --------- src/Builder/Projection/ElemMatchOperator.php | 47 -------------------- src/Builder/Projection/FactoryTrait.php | 28 ------------ src/Builder/Type/ProjectionInterface.php | 14 ------ 6 files changed, 117 deletions(-) delete mode 100644 src/Builder/Projection.php delete mode 100644 src/Builder/Projection/ElemMatchOperator.php delete mode 100644 src/Builder/Projection/FactoryTrait.php delete mode 100644 src/Builder/Type/ProjectionInterface.php diff --git a/.gitattributes b/.gitattributes index 7f54ebe53..75618ae42 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,6 +22,5 @@ rector.php export-ignore /src/Builder/Accumulator/*.php linguist-generated=true /src/Builder/Expression/*.php linguist-generated=true /src/Builder/Query/*.php linguist-generated=true -/src/Builder/Projection/*.php linguist-generated=true /src/Builder/Stage/*.php linguist-generated=true /tests/Builder/*/Pipelines.php linguist-generated=true diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ba4f3cb4f..4619f8206 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -90,11 +90,6 @@ - - - - - diff --git a/src/Builder/Projection.php b/src/Builder/Projection.php deleted file mode 100644 index e8e90f7f6..000000000 --- a/src/Builder/Projection.php +++ /dev/null @@ -1,22 +0,0 @@ -query = $query; - } - - public function getOperator(): string - { - return '$elemMatch'; - } -} diff --git a/src/Builder/Projection/FactoryTrait.php b/src/Builder/Projection/FactoryTrait.php deleted file mode 100644 index 359926ded..000000000 --- a/src/Builder/Projection/FactoryTrait.php +++ /dev/null @@ -1,28 +0,0 @@ - Date: Mon, 2 Dec 2024 22:40:10 +0100 Subject: [PATCH 2/5] Remove specific encoder for `Group` and `DollarGroup`, use property name map (#1540) --- generator/README.md | 25 ++++-- 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 | 5 ++ .../src/Definition/OperatorDefinition.php | 2 - generator/src/OperatorClassGenerator.php | 73 ++++++++++-------- generator/src/OperatorFactoryGenerator.php | 10 +-- 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 | 76 +++++-------------- 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, 528 insertions(+), 141 deletions(-) diff --git a/generator/README.md b/generator/README.md index 5b6449543..3e18976f9 100644 --- a/generator/README.md +++ b/generator/README.md @@ -10,17 +10,31 @@ 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. If it starts with `$`, the dollar is trimmed from the class property name | +| `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 | +| `mergeObject` | `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 +44,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..4df3a43de 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 + mergeObject: true type: - geometry tests: diff --git a/generator/config/query/geoWithin.yaml b/generator/config/query/geoWithin.yaml index 3a87e4b72..f9f6204d0 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 + mergeObject: true type: - geometry tests: diff --git a/generator/config/query/near.yaml b/generator/config/query/near.yaml index f2c791630..89d7f511f 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 + mergeObject: 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..72e8e18e9 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 + mergeObject: 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..61846e3e7 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"] + }, + "mergeObject": { + "$comment": "Skip the name in object encoding and merge the properties of the value into the operator", + "type": "boolean", + "default": false } }, "required": [ diff --git a/generator/config/stage/group.yaml b/generator/config/stage/group.yaml index 3e93588e9..a4bae60c2 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 + mergeObject: true type: - accumulator variadic: object diff --git a/generator/src/Definition/ArgumentDefinition.php b/generator/src/Definition/ArgumentDefinition.php index e45ea0da3..7cdd7d321 100644 --- a/generator/src/Definition/ArgumentDefinition.php +++ b/generator/src/Definition/ArgumentDefinition.php @@ -9,10 +9,12 @@ use function get_debug_type; use function is_array; use function is_string; +use function ltrim; use function sprintf; final class ArgumentDefinition { + public string $propertyName; public VariadicType|null $variadic; public int|null $variadicMin; @@ -25,6 +27,7 @@ public function __construct( string|null $variadic = null, int|null $variadicMin = null, public mixed $default = null, + public bool $mergeObject = false, ) { assert($this->optional === false || $this->default === null, 'Optional arguments cannot have a default value'); if (is_array($type)) { @@ -34,6 +37,8 @@ public function __construct( } } + $this->propertyName = ltrim($this->name, '$'); + if ($variadic) { $this->variadic = VariadicType::from($variadic); if ($variadicMin === null) { 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..1bf0af32f 100644 --- a/generator/src/OperatorClassGenerator.php +++ b/generator/src/OperatorClassGenerator.php @@ -61,27 +61,30 @@ 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) { + $encodeNames[$argument->propertyName] = $argument->mergeObject ? null : $argument->name; + $type = $this->getAcceptedTypes($argument); foreach ($type->use as $use) { $namespace->addUse($use); } - $property = $class->addProperty($argument->name); + $property = $class->addProperty($argument->propertyName); $property->setReadOnly(); - $constuctorParam = $constuctor->addParameter($argument->name); - $constuctorParam->setType($type->native); + $constructorParam = $constructor->addParameter($argument->propertyName); + $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 . ' ...$' . $argument->propertyName . 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(<<propertyName}) < {$argument->variadicMin}) { + throw new InvalidArgumentException(\sprintf('Expected at least %d values for \${$argument->propertyName}, got %d.', {$argument->variadicMin}, \count(\${$argument->propertyName}))); } PHP); @@ -89,45 +92,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 . '> $' . $argument->propertyName . 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(<<propertyName})) { + throw new InvalidArgumentException('Expected \${$argument->propertyName} arguments to be a list (array), named arguments are not supported'); } PHP); } elseif ($argument->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 . '> $' . $argument->propertyName . rtrim(' ' . $argument->description)); $namespace->addUseFunction('is_string'); $namespace->addUse(InvalidArgumentException::class); - $constuctor->addBody(<<name} as \$key => \$value) { + $constructor->addBody(<<propertyName} as \$key => \$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 \${$argument->propertyName} arguments to be a map (object), named arguments (:) or array unpacking ...[\'\' => ] must be used'); } } - \${$argument->name} = (object) \${$argument->name}; + \${$argument->propertyName} = (object) \${$argument->propertyName}; PHP); } } else { // Non-variadic arguments - $property->addComment('@var ' . $type->doc . ' $' . $argument->name . rtrim(' ' . $argument->description)); + $property->addComment('@var ' . $type->doc . ' $' . $argument->propertyName . rtrim(' ' . $argument->description)); $property->setType($type->native); - $constuctor->addComment('@param ' . $type->doc . ' $' . $argument->name . rtrim(' ' . $argument->description)); + $constructor->addComment('@param ' . $type->doc . ' $' . $argument->propertyName . 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 +138,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(<<propertyName}) && ! array_is_list(\${$argument->propertyName})) { + throw new InvalidArgumentException('Expected \${$argument->propertyName} argument to be a list, got an associative array.'); } PHP); @@ -146,9 +149,9 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition if ($type->query) { $namespace->addUseFunction('is_array'); $namespace->addUse(QueryObject::class); - $constuctor->addBody(<<name})) { - \${$argument->name} = QueryObject::create(\${$argument->name}); + $constructor->addBody(<<propertyName})) { + \${$argument->propertyName} = QueryObject::create(\${$argument->propertyName}); } PHP); @@ -157,9 +160,9 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition if ($type->javascript) { $namespace->addUseFunction('is_string'); $namespace->addUse(Javascript::class); - $constuctor->addBody(<<name})) { - \${$argument->name} = new Javascript(\${$argument->name}); + $constructor->addBody(<<propertyName})) { + \${$argument->propertyName} = new Javascript(\${$argument->propertyName}); } PHP); @@ -167,7 +170,11 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition } // Set property from constructor argument - $constuctor->addBody('$this->' . $argument->name . ' = $' . $argument->name . ';'); + $constructor->addBody('$this->' . $argument->propertyName . ' = $' . $argument->propertyName . ';'); + } + + if ($encodeNames !== []) { + $class->addConstant('PROPERTIES', $encodeNames); } $class->addMethod('getOperator') diff --git a/generator/src/OperatorFactoryGenerator.php b/generator/src/OperatorFactoryGenerator.php index 0bc27620f..e60804ad8 100644 --- a/generator/src/OperatorFactoryGenerator.php +++ b/generator/src/OperatorFactoryGenerator.php @@ -65,7 +65,7 @@ private function addMethod(GeneratorDefinition $definition, OperatorDefinition $ $namespace->addUse($use); } - $parameter = $method->addParameter($argument->name); + $parameter = $method->addParameter($argument->propertyName); $parameter->setType($type->native); if ($argument->variadic) { if ($argument->variadic === VariadicType::Array) { @@ -75,8 +75,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 . ' ...$' . $argument->propertyName . rtrim(' ' . $argument->description)); + $args[] = '...$' . $argument->propertyName; } else { if ($argument->optional) { $parameter->setDefaultValue(new Literal('Optional::Undefined')); @@ -84,8 +84,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 . ' $' . $argument->propertyName . rtrim(' ' . $argument->description)); + $args[] = '$' . $argument->propertyName; } } 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..4996c7c3f 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,31 @@ 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); + // The name is null for arguments with "mergeObject: true" in the YAML file, + // the value properties are merged into the parent object. + 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 +96,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; } From 9fc0d426586e5b47edac92d8b366726517ec73e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 2 Dec 2024 22:43:33 +0100 Subject: [PATCH 3/5] Mark builder classes as final and internal (#1542) --- generator/src/OperatorClassGenerator.php | 2 ++ src/Builder/Accumulator/AccumulatorAccumulator.php | 3 ++- src/Builder/Accumulator/AddToSetAccumulator.php | 3 ++- src/Builder/Accumulator/AvgAccumulator.php | 3 ++- src/Builder/Accumulator/BottomAccumulator.php | 3 ++- src/Builder/Accumulator/BottomNAccumulator.php | 3 ++- src/Builder/Accumulator/CountAccumulator.php | 3 ++- src/Builder/Accumulator/CovariancePopAccumulator.php | 3 ++- src/Builder/Accumulator/CovarianceSampAccumulator.php | 3 ++- src/Builder/Accumulator/DenseRankAccumulator.php | 3 ++- src/Builder/Accumulator/DerivativeAccumulator.php | 3 ++- src/Builder/Accumulator/DocumentNumberAccumulator.php | 3 ++- src/Builder/Accumulator/ExpMovingAvgAccumulator.php | 3 ++- src/Builder/Accumulator/FirstAccumulator.php | 3 ++- src/Builder/Accumulator/FirstNAccumulator.php | 3 ++- src/Builder/Accumulator/IntegralAccumulator.php | 3 ++- src/Builder/Accumulator/LastAccumulator.php | 3 ++- src/Builder/Accumulator/LastNAccumulator.php | 3 ++- src/Builder/Accumulator/LinearFillAccumulator.php | 3 ++- src/Builder/Accumulator/LocfAccumulator.php | 3 ++- src/Builder/Accumulator/MaxAccumulator.php | 3 ++- src/Builder/Accumulator/MaxNAccumulator.php | 3 ++- src/Builder/Accumulator/MedianAccumulator.php | 3 ++- src/Builder/Accumulator/MergeObjectsAccumulator.php | 3 ++- src/Builder/Accumulator/MinAccumulator.php | 3 ++- src/Builder/Accumulator/MinNAccumulator.php | 3 ++- src/Builder/Accumulator/PercentileAccumulator.php | 3 ++- src/Builder/Accumulator/PushAccumulator.php | 3 ++- src/Builder/Accumulator/RankAccumulator.php | 3 ++- src/Builder/Accumulator/ShiftAccumulator.php | 3 ++- src/Builder/Accumulator/StdDevPopAccumulator.php | 3 ++- src/Builder/Accumulator/StdDevSampAccumulator.php | 3 ++- src/Builder/Accumulator/SumAccumulator.php | 3 ++- src/Builder/Accumulator/TopAccumulator.php | 3 ++- src/Builder/Accumulator/TopNAccumulator.php | 3 ++- src/Builder/BuilderEncoder.php | 2 +- src/Builder/Encoder/AbstractExpressionEncoder.php | 1 + src/Builder/Encoder/CombinedFieldQueryEncoder.php | 7 +++++-- src/Builder/Encoder/DictionaryEncoder.php | 7 +++++-- src/Builder/Encoder/ExpressionEncoder.php | 1 + src/Builder/Encoder/FieldPathEncoder.php | 8 +++++--- src/Builder/Encoder/OperatorEncoder.php | 7 +++++-- src/Builder/Encoder/OutputWindowEncoder.php | 7 +++++-- src/Builder/Encoder/PipelineEncoder.php | 7 +++++-- src/Builder/Encoder/QueryEncoder.php | 7 +++++-- src/Builder/Encoder/VariableEncoder.php | 7 +++++-- src/Builder/Expression/AbsOperator.php | 3 ++- src/Builder/Expression/AcosOperator.php | 3 ++- src/Builder/Expression/AcoshOperator.php | 3 ++- src/Builder/Expression/AddOperator.php | 3 ++- src/Builder/Expression/AllElementsTrueOperator.php | 3 ++- src/Builder/Expression/AndOperator.php | 3 ++- src/Builder/Expression/AnyElementTrueOperator.php | 3 ++- src/Builder/Expression/ArrayElemAtOperator.php | 3 ++- src/Builder/Expression/ArrayToObjectOperator.php | 3 ++- src/Builder/Expression/AsinOperator.php | 3 ++- src/Builder/Expression/AsinhOperator.php | 3 ++- src/Builder/Expression/Atan2Operator.php | 3 ++- src/Builder/Expression/AtanOperator.php | 3 ++- src/Builder/Expression/AtanhOperator.php | 3 ++- src/Builder/Expression/AvgOperator.php | 3 ++- src/Builder/Expression/BinarySizeOperator.php | 3 ++- src/Builder/Expression/BitAndOperator.php | 3 ++- src/Builder/Expression/BitNotOperator.php | 3 ++- src/Builder/Expression/BitOrOperator.php | 3 ++- src/Builder/Expression/BitXorOperator.php | 3 ++- src/Builder/Expression/BsonSizeOperator.php | 3 ++- src/Builder/Expression/CaseOperator.php | 3 ++- src/Builder/Expression/CeilOperator.php | 3 ++- src/Builder/Expression/CmpOperator.php | 3 ++- src/Builder/Expression/ConcatArraysOperator.php | 3 ++- src/Builder/Expression/ConcatOperator.php | 3 ++- src/Builder/Expression/CondOperator.php | 3 ++- src/Builder/Expression/ConvertOperator.php | 3 ++- src/Builder/Expression/CosOperator.php | 3 ++- src/Builder/Expression/CoshOperator.php | 3 ++- src/Builder/Expression/DateAddOperator.php | 3 ++- src/Builder/Expression/DateDiffOperator.php | 3 ++- src/Builder/Expression/DateFromPartsOperator.php | 3 ++- src/Builder/Expression/DateFromStringOperator.php | 3 ++- src/Builder/Expression/DateSubtractOperator.php | 3 ++- src/Builder/Expression/DateToPartsOperator.php | 3 ++- src/Builder/Expression/DateToStringOperator.php | 3 ++- src/Builder/Expression/DateTruncOperator.php | 3 ++- src/Builder/Expression/DayOfMonthOperator.php | 3 ++- src/Builder/Expression/DayOfWeekOperator.php | 3 ++- src/Builder/Expression/DayOfYearOperator.php | 3 ++- src/Builder/Expression/DegreesToRadiansOperator.php | 3 ++- src/Builder/Expression/DivideOperator.php | 3 ++- src/Builder/Expression/EqOperator.php | 3 ++- src/Builder/Expression/ExpOperator.php | 3 ++- src/Builder/Expression/FilterOperator.php | 3 ++- src/Builder/Expression/FirstNOperator.php | 3 ++- src/Builder/Expression/FirstOperator.php | 3 ++- src/Builder/Expression/FloorOperator.php | 3 ++- src/Builder/Expression/FunctionOperator.php | 3 ++- src/Builder/Expression/GetFieldOperator.php | 3 ++- src/Builder/Expression/GtOperator.php | 3 ++- src/Builder/Expression/GteOperator.php | 3 ++- src/Builder/Expression/HourOperator.php | 3 ++- src/Builder/Expression/IfNullOperator.php | 3 ++- src/Builder/Expression/InOperator.php | 3 ++- src/Builder/Expression/IndexOfArrayOperator.php | 3 ++- src/Builder/Expression/IndexOfBytesOperator.php | 3 ++- src/Builder/Expression/IndexOfCPOperator.php | 3 ++- src/Builder/Expression/IsArrayOperator.php | 3 ++- src/Builder/Expression/IsNumberOperator.php | 3 ++- src/Builder/Expression/IsoDayOfWeekOperator.php | 3 ++- src/Builder/Expression/IsoWeekOperator.php | 3 ++- src/Builder/Expression/IsoWeekYearOperator.php | 3 ++- src/Builder/Expression/LastNOperator.php | 3 ++- src/Builder/Expression/LastOperator.php | 3 ++- src/Builder/Expression/LetOperator.php | 3 ++- src/Builder/Expression/LiteralOperator.php | 3 ++- src/Builder/Expression/LnOperator.php | 3 ++- src/Builder/Expression/Log10Operator.php | 3 ++- src/Builder/Expression/LogOperator.php | 3 ++- src/Builder/Expression/LtOperator.php | 3 ++- src/Builder/Expression/LteOperator.php | 3 ++- src/Builder/Expression/LtrimOperator.php | 3 ++- src/Builder/Expression/MapOperator.php | 3 ++- src/Builder/Expression/MaxNOperator.php | 3 ++- src/Builder/Expression/MaxOperator.php | 3 ++- src/Builder/Expression/MedianOperator.php | 3 ++- src/Builder/Expression/MergeObjectsOperator.php | 3 ++- src/Builder/Expression/MetaOperator.php | 3 ++- src/Builder/Expression/MillisecondOperator.php | 3 ++- src/Builder/Expression/MinNOperator.php | 3 ++- src/Builder/Expression/MinOperator.php | 3 ++- src/Builder/Expression/MinuteOperator.php | 3 ++- src/Builder/Expression/ModOperator.php | 3 ++- src/Builder/Expression/MonthOperator.php | 3 ++- src/Builder/Expression/MultiplyOperator.php | 3 ++- src/Builder/Expression/NeOperator.php | 3 ++- src/Builder/Expression/NotOperator.php | 3 ++- src/Builder/Expression/ObjectToArrayOperator.php | 3 ++- src/Builder/Expression/OrOperator.php | 3 ++- src/Builder/Expression/PercentileOperator.php | 3 ++- src/Builder/Expression/PowOperator.php | 3 ++- src/Builder/Expression/RadiansToDegreesOperator.php | 3 ++- src/Builder/Expression/RandOperator.php | 3 ++- src/Builder/Expression/RangeOperator.php | 3 ++- src/Builder/Expression/ReduceOperator.php | 3 ++- src/Builder/Expression/RegexFindAllOperator.php | 3 ++- src/Builder/Expression/RegexFindOperator.php | 3 ++- src/Builder/Expression/RegexMatchOperator.php | 3 ++- src/Builder/Expression/ReplaceAllOperator.php | 3 ++- src/Builder/Expression/ReplaceOneOperator.php | 3 ++- src/Builder/Expression/ReverseArrayOperator.php | 3 ++- src/Builder/Expression/RoundOperator.php | 3 ++- src/Builder/Expression/RtrimOperator.php | 3 ++- src/Builder/Expression/SecondOperator.php | 3 ++- src/Builder/Expression/SetDifferenceOperator.php | 3 ++- src/Builder/Expression/SetEqualsOperator.php | 3 ++- src/Builder/Expression/SetFieldOperator.php | 3 ++- src/Builder/Expression/SetIntersectionOperator.php | 3 ++- src/Builder/Expression/SetIsSubsetOperator.php | 3 ++- src/Builder/Expression/SetUnionOperator.php | 3 ++- src/Builder/Expression/SinOperator.php | 3 ++- src/Builder/Expression/SinhOperator.php | 3 ++- src/Builder/Expression/SizeOperator.php | 3 ++- src/Builder/Expression/SliceOperator.php | 3 ++- src/Builder/Expression/SortArrayOperator.php | 3 ++- src/Builder/Expression/SplitOperator.php | 3 ++- src/Builder/Expression/SqrtOperator.php | 3 ++- src/Builder/Expression/StdDevPopOperator.php | 3 ++- src/Builder/Expression/StdDevSampOperator.php | 3 ++- src/Builder/Expression/StrLenBytesOperator.php | 3 ++- src/Builder/Expression/StrLenCPOperator.php | 3 ++- src/Builder/Expression/StrcasecmpOperator.php | 3 ++- src/Builder/Expression/SubstrBytesOperator.php | 3 ++- src/Builder/Expression/SubstrCPOperator.php | 3 ++- src/Builder/Expression/SubstrOperator.php | 3 ++- src/Builder/Expression/SubtractOperator.php | 3 ++- src/Builder/Expression/SumOperator.php | 3 ++- src/Builder/Expression/SwitchOperator.php | 3 ++- src/Builder/Expression/TanOperator.php | 3 ++- src/Builder/Expression/TanhOperator.php | 3 ++- src/Builder/Expression/ToBoolOperator.php | 3 ++- src/Builder/Expression/ToDateOperator.php | 3 ++- src/Builder/Expression/ToDecimalOperator.php | 3 ++- src/Builder/Expression/ToDoubleOperator.php | 3 ++- src/Builder/Expression/ToHashedIndexKeyOperator.php | 3 ++- src/Builder/Expression/ToIntOperator.php | 3 ++- src/Builder/Expression/ToLongOperator.php | 3 ++- src/Builder/Expression/ToLowerOperator.php | 3 ++- src/Builder/Expression/ToObjectIdOperator.php | 3 ++- src/Builder/Expression/ToStringOperator.php | 3 ++- src/Builder/Expression/ToUpperOperator.php | 3 ++- src/Builder/Expression/TrimOperator.php | 3 ++- src/Builder/Expression/TruncOperator.php | 3 ++- src/Builder/Expression/TsIncrementOperator.php | 3 ++- src/Builder/Expression/TsSecondOperator.php | 3 ++- src/Builder/Expression/TypeOperator.php | 3 ++- src/Builder/Expression/UnsetFieldOperator.php | 3 ++- src/Builder/Expression/WeekOperator.php | 3 ++- src/Builder/Expression/YearOperator.php | 3 ++- src/Builder/Expression/ZipOperator.php | 3 ++- src/Builder/Query/AllOperator.php | 3 ++- src/Builder/Query/AndOperator.php | 3 ++- src/Builder/Query/BitsAllClearOperator.php | 3 ++- src/Builder/Query/BitsAllSetOperator.php | 3 ++- src/Builder/Query/BitsAnyClearOperator.php | 3 ++- src/Builder/Query/BitsAnySetOperator.php | 3 ++- src/Builder/Query/BoxOperator.php | 3 ++- src/Builder/Query/CenterOperator.php | 3 ++- src/Builder/Query/CenterSphereOperator.php | 3 ++- src/Builder/Query/CommentOperator.php | 3 ++- src/Builder/Query/ElemMatchOperator.php | 3 ++- src/Builder/Query/EqOperator.php | 3 ++- src/Builder/Query/ExistsOperator.php | 3 ++- src/Builder/Query/ExprOperator.php | 3 ++- src/Builder/Query/GeoIntersectsOperator.php | 3 ++- src/Builder/Query/GeoWithinOperator.php | 3 ++- src/Builder/Query/GeometryOperator.php | 3 ++- src/Builder/Query/GtOperator.php | 3 ++- src/Builder/Query/GteOperator.php | 3 ++- src/Builder/Query/InOperator.php | 3 ++- src/Builder/Query/JsonSchemaOperator.php | 3 ++- src/Builder/Query/LtOperator.php | 3 ++- src/Builder/Query/LteOperator.php | 3 ++- src/Builder/Query/MaxDistanceOperator.php | 3 ++- src/Builder/Query/MinDistanceOperator.php | 3 ++- src/Builder/Query/ModOperator.php | 3 ++- src/Builder/Query/NeOperator.php | 3 ++- src/Builder/Query/NearOperator.php | 3 ++- src/Builder/Query/NearSphereOperator.php | 3 ++- src/Builder/Query/NinOperator.php | 3 ++- src/Builder/Query/NorOperator.php | 3 ++- src/Builder/Query/NotOperator.php | 3 ++- src/Builder/Query/OrOperator.php | 3 ++- src/Builder/Query/PolygonOperator.php | 3 ++- src/Builder/Query/RandOperator.php | 3 ++- src/Builder/Query/RegexOperator.php | 3 ++- src/Builder/Query/SampleRateOperator.php | 3 ++- src/Builder/Query/SizeOperator.php | 3 ++- src/Builder/Query/TextOperator.php | 3 ++- src/Builder/Query/TypeOperator.php | 3 ++- src/Builder/Query/WhereOperator.php | 3 ++- src/Builder/Stage/AddFieldsStage.php | 3 ++- src/Builder/Stage/BucketAutoStage.php | 3 ++- src/Builder/Stage/BucketStage.php | 3 ++- src/Builder/Stage/ChangeStreamSplitLargeEventStage.php | 3 ++- src/Builder/Stage/ChangeStreamStage.php | 3 ++- src/Builder/Stage/CollStatsStage.php | 3 ++- src/Builder/Stage/CountStage.php | 3 ++- src/Builder/Stage/CurrentOpStage.php | 3 ++- src/Builder/Stage/DensifyStage.php | 3 ++- src/Builder/Stage/DocumentsStage.php | 3 ++- src/Builder/Stage/FacetStage.php | 3 ++- src/Builder/Stage/FillStage.php | 3 ++- src/Builder/Stage/GeoNearStage.php | 3 ++- src/Builder/Stage/GraphLookupStage.php | 3 ++- src/Builder/Stage/GroupStage.php | 3 ++- src/Builder/Stage/IndexStatsStage.php | 3 ++- src/Builder/Stage/LimitStage.php | 3 ++- src/Builder/Stage/ListLocalSessionsStage.php | 3 ++- src/Builder/Stage/ListSampledQueriesStage.php | 3 ++- src/Builder/Stage/ListSearchIndexesStage.php | 3 ++- src/Builder/Stage/ListSessionsStage.php | 3 ++- src/Builder/Stage/LookupStage.php | 3 ++- src/Builder/Stage/MatchStage.php | 3 ++- src/Builder/Stage/MergeStage.php | 3 ++- src/Builder/Stage/OutStage.php | 3 ++- src/Builder/Stage/PlanCacheStatsStage.php | 3 ++- src/Builder/Stage/ProjectStage.php | 3 ++- src/Builder/Stage/RedactStage.php | 3 ++- src/Builder/Stage/ReplaceRootStage.php | 3 ++- src/Builder/Stage/ReplaceWithStage.php | 3 ++- src/Builder/Stage/SampleStage.php | 3 ++- src/Builder/Stage/SearchMetaStage.php | 3 ++- src/Builder/Stage/SearchStage.php | 3 ++- src/Builder/Stage/SetStage.php | 3 ++- src/Builder/Stage/SetWindowFieldsStage.php | 3 ++- src/Builder/Stage/ShardedDataDistributionStage.php | 3 ++- src/Builder/Stage/SkipStage.php | 3 ++- src/Builder/Stage/SortByCountStage.php | 3 ++- src/Builder/Stage/SortStage.php | 3 ++- src/Builder/Stage/UnionWithStage.php | 3 ++- src/Builder/Stage/UnsetStage.php | 3 ++- src/Builder/Stage/UnwindStage.php | 3 ++- src/Builder/Type/CombinedFieldQuery.php | 4 +++- src/Builder/Type/Encode.php | 1 + src/Builder/Type/OutputWindow.php | 2 +- 284 files changed, 588 insertions(+), 289 deletions(-) diff --git a/generator/src/OperatorClassGenerator.php b/generator/src/OperatorClassGenerator.php index 1bf0af32f..e51a1979d 100644 --- a/generator/src/OperatorClassGenerator.php +++ b/generator/src/OperatorClassGenerator.php @@ -50,6 +50,7 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition } $class = $namespace->addClass($this->getOperatorClassName($definition, $operator)); + $class->setFinal(); $class->setImplements($interfaces); $namespace->addUse(OperatorInterface::class); $class->addImplement(OperatorInterface::class); @@ -58,6 +59,7 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition // @todo move to encoder class $class->addComment($operator->description); $class->addComment('@see ' . $operator->link); + $class->addComment('@internal'); $namespace->addUse(Encode::class); $class->addConstant('ENCODE', new Literal('Encode::' . $operator->encode->name)); diff --git a/src/Builder/Accumulator/AccumulatorAccumulator.php b/src/Builder/Accumulator/AccumulatorAccumulator.php index 911dff36e..6a5cdd06b 100644 --- a/src/Builder/Accumulator/AccumulatorAccumulator.php +++ b/src/Builder/Accumulator/AccumulatorAccumulator.php @@ -27,8 +27,9 @@ * New in MongoDB 4.4. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/ + * @internal */ -class AccumulatorAccumulator implements AccumulatorInterface, OperatorInterface +final class AccumulatorAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Accumulator/AddToSetAccumulator.php b/src/Builder/Accumulator/AddToSetAccumulator.php index 345fbca6f..70be4bdbe 100644 --- a/src/Builder/Accumulator/AddToSetAccumulator.php +++ b/src/Builder/Accumulator/AddToSetAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/ + * @internal */ -class AddToSetAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class AddToSetAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/AvgAccumulator.php b/src/Builder/Accumulator/AvgAccumulator.php index 832940275..034fa776b 100644 --- a/src/Builder/Accumulator/AvgAccumulator.php +++ b/src/Builder/Accumulator/AvgAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/ + * @internal */ -class AvgAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class AvgAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/BottomAccumulator.php b/src/Builder/Accumulator/BottomAccumulator.php index da90cfe98..f001d6e04 100644 --- a/src/Builder/Accumulator/BottomAccumulator.php +++ b/src/Builder/Accumulator/BottomAccumulator.php @@ -23,8 +23,9 @@ * New in MongoDB 5.2: Available in the $group and $setWindowFields stages. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/ + * @internal */ -class BottomAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class BottomAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output']; diff --git a/src/Builder/Accumulator/BottomNAccumulator.php b/src/Builder/Accumulator/BottomNAccumulator.php index aee2d5f70..4e2f5705c 100644 --- a/src/Builder/Accumulator/BottomNAccumulator.php +++ b/src/Builder/Accumulator/BottomNAccumulator.php @@ -25,8 +25,9 @@ * Available in the $group and $setWindowFields stages. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/ + * @internal */ -class BottomNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class BottomNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['n' => 'n', 'sortBy' => 'sortBy', 'output' => 'output']; diff --git a/src/Builder/Accumulator/CountAccumulator.php b/src/Builder/Accumulator/CountAccumulator.php index 384996417..699eedc16 100644 --- a/src/Builder/Accumulator/CountAccumulator.php +++ b/src/Builder/Accumulator/CountAccumulator.php @@ -19,8 +19,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/count-accumulator/ + * @internal */ -class CountAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class CountAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Accumulator/CovariancePopAccumulator.php b/src/Builder/Accumulator/CovariancePopAccumulator.php index bb864a282..f23170329 100644 --- a/src/Builder/Accumulator/CovariancePopAccumulator.php +++ b/src/Builder/Accumulator/CovariancePopAccumulator.php @@ -20,8 +20,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/ + * @internal */ -class CovariancePopAccumulator implements WindowInterface, OperatorInterface +final class CovariancePopAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Accumulator/CovarianceSampAccumulator.php b/src/Builder/Accumulator/CovarianceSampAccumulator.php index 96dc1a438..b99d1cdda 100644 --- a/src/Builder/Accumulator/CovarianceSampAccumulator.php +++ b/src/Builder/Accumulator/CovarianceSampAccumulator.php @@ -20,8 +20,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/ + * @internal */ -class CovarianceSampAccumulator implements WindowInterface, OperatorInterface +final class CovarianceSampAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Accumulator/DenseRankAccumulator.php b/src/Builder/Accumulator/DenseRankAccumulator.php index 7dea1de67..820a9fe36 100644 --- a/src/Builder/Accumulator/DenseRankAccumulator.php +++ b/src/Builder/Accumulator/DenseRankAccumulator.php @@ -17,8 +17,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/ + * @internal */ -class DenseRankAccumulator implements WindowInterface, OperatorInterface +final class DenseRankAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Accumulator/DerivativeAccumulator.php b/src/Builder/Accumulator/DerivativeAccumulator.php index 125fda6b9..80b111a2d 100644 --- a/src/Builder/Accumulator/DerivativeAccumulator.php +++ b/src/Builder/Accumulator/DerivativeAccumulator.php @@ -25,8 +25,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/ + * @internal */ -class DerivativeAccumulator implements WindowInterface, OperatorInterface +final class DerivativeAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'unit' => 'unit']; diff --git a/src/Builder/Accumulator/DocumentNumberAccumulator.php b/src/Builder/Accumulator/DocumentNumberAccumulator.php index 4318dbd81..ae776659e 100644 --- a/src/Builder/Accumulator/DocumentNumberAccumulator.php +++ b/src/Builder/Accumulator/DocumentNumberAccumulator.php @@ -17,8 +17,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/ + * @internal */ -class DocumentNumberAccumulator implements WindowInterface, OperatorInterface +final class DocumentNumberAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Accumulator/ExpMovingAvgAccumulator.php b/src/Builder/Accumulator/ExpMovingAvgAccumulator.php index 4231acb08..44999b734 100644 --- a/src/Builder/Accumulator/ExpMovingAvgAccumulator.php +++ b/src/Builder/Accumulator/ExpMovingAvgAccumulator.php @@ -21,8 +21,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/ + * @internal */ -class ExpMovingAvgAccumulator implements WindowInterface, OperatorInterface +final class ExpMovingAvgAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'N' => 'N', 'alpha' => 'alpha']; diff --git a/src/Builder/Accumulator/FirstAccumulator.php b/src/Builder/Accumulator/FirstAccumulator.php index 2a2ac1c36..2e4ff57ae 100644 --- a/src/Builder/Accumulator/FirstAccumulator.php +++ b/src/Builder/Accumulator/FirstAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/ + * @internal */ -class FirstAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class FirstAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/FirstNAccumulator.php b/src/Builder/Accumulator/FirstNAccumulator.php index 0f8607752..844a9ff9f 100644 --- a/src/Builder/Accumulator/FirstNAccumulator.php +++ b/src/Builder/Accumulator/FirstNAccumulator.php @@ -23,8 +23,9 @@ * If the group contains fewer than n elements, $firstN returns all elements in the group. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN/ + * @internal */ -class FirstNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class FirstNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'n' => 'n']; diff --git a/src/Builder/Accumulator/IntegralAccumulator.php b/src/Builder/Accumulator/IntegralAccumulator.php index 6e66b2232..3255fc328 100644 --- a/src/Builder/Accumulator/IntegralAccumulator.php +++ b/src/Builder/Accumulator/IntegralAccumulator.php @@ -25,8 +25,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/ + * @internal */ -class IntegralAccumulator implements WindowInterface, OperatorInterface +final class IntegralAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'unit' => 'unit']; diff --git a/src/Builder/Accumulator/LastAccumulator.php b/src/Builder/Accumulator/LastAccumulator.php index f94ce7759..b568fe77c 100644 --- a/src/Builder/Accumulator/LastAccumulator.php +++ b/src/Builder/Accumulator/LastAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ + * @internal */ -class LastAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class LastAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/LastNAccumulator.php b/src/Builder/Accumulator/LastNAccumulator.php index b1be48efd..75fa90c36 100644 --- a/src/Builder/Accumulator/LastNAccumulator.php +++ b/src/Builder/Accumulator/LastNAccumulator.php @@ -27,8 +27,9 @@ * If the group contains fewer than n elements, $lastN returns all elements in the group. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/ + * @internal */ -class LastNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class LastNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'n' => 'n']; diff --git a/src/Builder/Accumulator/LinearFillAccumulator.php b/src/Builder/Accumulator/LinearFillAccumulator.php index 8da65cfda..3ca8f52c6 100644 --- a/src/Builder/Accumulator/LinearFillAccumulator.php +++ b/src/Builder/Accumulator/LinearFillAccumulator.php @@ -21,8 +21,9 @@ * New in MongoDB 5.3. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/ + * @internal */ -class LinearFillAccumulator implements WindowInterface, OperatorInterface +final class LinearFillAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/LocfAccumulator.php b/src/Builder/Accumulator/LocfAccumulator.php index 5cfa9b6e7..0ecc6002a 100644 --- a/src/Builder/Accumulator/LocfAccumulator.php +++ b/src/Builder/Accumulator/LocfAccumulator.php @@ -21,8 +21,9 @@ * New in MongoDB 5.2. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/ + * @internal */ -class LocfAccumulator implements WindowInterface, OperatorInterface +final class LocfAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/MaxAccumulator.php b/src/Builder/Accumulator/MaxAccumulator.php index 29a7cb630..3eaf66b3c 100644 --- a/src/Builder/Accumulator/MaxAccumulator.php +++ b/src/Builder/Accumulator/MaxAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/ + * @internal */ -class MaxAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class MaxAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/MaxNAccumulator.php b/src/Builder/Accumulator/MaxNAccumulator.php index 551dc47f9..01f2a3430 100644 --- a/src/Builder/Accumulator/MaxNAccumulator.php +++ b/src/Builder/Accumulator/MaxNAccumulator.php @@ -25,8 +25,9 @@ * Returns the n largest values in an array. Distinct from the $maxN accumulator. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN/ + * @internal */ -class MaxNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class MaxNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'n' => 'n']; diff --git a/src/Builder/Accumulator/MedianAccumulator.php b/src/Builder/Accumulator/MedianAccumulator.php index aa4d92553..83e32ea15 100644 --- a/src/Builder/Accumulator/MedianAccumulator.php +++ b/src/Builder/Accumulator/MedianAccumulator.php @@ -25,8 +25,9 @@ * It is also available as an aggregation expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/ + * @internal */ -class MedianAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class MedianAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'method' => 'method']; diff --git a/src/Builder/Accumulator/MergeObjectsAccumulator.php b/src/Builder/Accumulator/MergeObjectsAccumulator.php index 1922598a3..0c4e1737c 100644 --- a/src/Builder/Accumulator/MergeObjectsAccumulator.php +++ b/src/Builder/Accumulator/MergeObjectsAccumulator.php @@ -20,8 +20,9 @@ * Combines multiple documents into a single document. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/ + * @internal */ -class MergeObjectsAccumulator implements AccumulatorInterface, OperatorInterface +final class MergeObjectsAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['document' => 'document']; diff --git a/src/Builder/Accumulator/MinAccumulator.php b/src/Builder/Accumulator/MinAccumulator.php index 7bb24dc0a..c2536772b 100644 --- a/src/Builder/Accumulator/MinAccumulator.php +++ b/src/Builder/Accumulator/MinAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/ + * @internal */ -class MinAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class MinAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/MinNAccumulator.php b/src/Builder/Accumulator/MinNAccumulator.php index f9f87a116..997859098 100644 --- a/src/Builder/Accumulator/MinNAccumulator.php +++ b/src/Builder/Accumulator/MinNAccumulator.php @@ -25,8 +25,9 @@ * Returns the n smallest values in an array. Distinct from the $minN accumulator. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN/ + * @internal */ -class MinNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class MinNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'n' => 'n']; diff --git a/src/Builder/Accumulator/PercentileAccumulator.php b/src/Builder/Accumulator/PercentileAccumulator.php index 8c8cdb9ca..a8d254ee1 100644 --- a/src/Builder/Accumulator/PercentileAccumulator.php +++ b/src/Builder/Accumulator/PercentileAccumulator.php @@ -35,8 +35,9 @@ * It is also available as an aggregation expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/ + * @internal */ -class PercentileAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class PercentileAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'p' => 'p', 'method' => 'method']; diff --git a/src/Builder/Accumulator/PushAccumulator.php b/src/Builder/Accumulator/PushAccumulator.php index 192df40c2..85a4282f5 100644 --- a/src/Builder/Accumulator/PushAccumulator.php +++ b/src/Builder/Accumulator/PushAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/ + * @internal */ -class PushAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class PushAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/RankAccumulator.php b/src/Builder/Accumulator/RankAccumulator.php index dd274dceb..9fea2d1f8 100644 --- a/src/Builder/Accumulator/RankAccumulator.php +++ b/src/Builder/Accumulator/RankAccumulator.php @@ -17,8 +17,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/ + * @internal */ -class RankAccumulator implements WindowInterface, OperatorInterface +final class RankAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Accumulator/ShiftAccumulator.php b/src/Builder/Accumulator/ShiftAccumulator.php index 257b11f36..85b39591b 100644 --- a/src/Builder/Accumulator/ShiftAccumulator.php +++ b/src/Builder/Accumulator/ShiftAccumulator.php @@ -20,8 +20,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/ + * @internal */ -class ShiftAccumulator implements WindowInterface, OperatorInterface +final class ShiftAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['output' => 'output', 'by' => 'by', 'default' => 'default']; diff --git a/src/Builder/Accumulator/StdDevPopAccumulator.php b/src/Builder/Accumulator/StdDevPopAccumulator.php index 1fadf83b9..faeeaf301 100644 --- a/src/Builder/Accumulator/StdDevPopAccumulator.php +++ b/src/Builder/Accumulator/StdDevPopAccumulator.php @@ -22,8 +22,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/ + * @internal */ -class StdDevPopAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class StdDevPopAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/StdDevSampAccumulator.php b/src/Builder/Accumulator/StdDevSampAccumulator.php index b48cdb0ac..e4a177636 100644 --- a/src/Builder/Accumulator/StdDevSampAccumulator.php +++ b/src/Builder/Accumulator/StdDevSampAccumulator.php @@ -22,8 +22,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/ + * @internal */ -class StdDevSampAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class StdDevSampAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/SumAccumulator.php b/src/Builder/Accumulator/SumAccumulator.php index 9e151c5c5..a2ad7af00 100644 --- a/src/Builder/Accumulator/SumAccumulator.php +++ b/src/Builder/Accumulator/SumAccumulator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ + * @internal */ -class SumAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface +final class SumAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Accumulator/TopAccumulator.php b/src/Builder/Accumulator/TopAccumulator.php index dd0f5a717..efad91414 100644 --- a/src/Builder/Accumulator/TopAccumulator.php +++ b/src/Builder/Accumulator/TopAccumulator.php @@ -24,8 +24,9 @@ * Available in the $group and $setWindowFields stages. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/ + * @internal */ -class TopAccumulator implements AccumulatorInterface, OperatorInterface +final class TopAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output']; diff --git a/src/Builder/Accumulator/TopNAccumulator.php b/src/Builder/Accumulator/TopNAccumulator.php index e3e23abca..ffcca2872 100644 --- a/src/Builder/Accumulator/TopNAccumulator.php +++ b/src/Builder/Accumulator/TopNAccumulator.php @@ -25,8 +25,9 @@ * Available in the $group and $setWindowFields stages. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/ + * @internal */ -class TopNAccumulator implements AccumulatorInterface, OperatorInterface +final class TopNAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['n' => 'n', 'sortBy' => 'sortBy', 'output' => 'output']; diff --git a/src/Builder/BuilderEncoder.php b/src/Builder/BuilderEncoder.php index 8b25325ce..0d7a5a90c 100644 --- a/src/Builder/BuilderEncoder.php +++ b/src/Builder/BuilderEncoder.php @@ -32,7 +32,7 @@ use function is_object; /** @template-implements Encoder */ -class BuilderEncoder implements Encoder +final class BuilderEncoder implements Encoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/AbstractExpressionEncoder.php b/src/Builder/Encoder/AbstractExpressionEncoder.php index 49d7a34f1..d593f4e3b 100644 --- a/src/Builder/Encoder/AbstractExpressionEncoder.php +++ b/src/Builder/Encoder/AbstractExpressionEncoder.php @@ -14,6 +14,7 @@ * @template BSONType of stdClass|array|string|int * @template NativeType * @template-implements ExpressionEncoder + * @internal */ abstract class AbstractExpressionEncoder implements ExpressionEncoder { diff --git a/src/Builder/Encoder/CombinedFieldQueryEncoder.php b/src/Builder/Encoder/CombinedFieldQueryEncoder.php index 4ad42396b..b933953be 100644 --- a/src/Builder/Encoder/CombinedFieldQueryEncoder.php +++ b/src/Builder/Encoder/CombinedFieldQueryEncoder.php @@ -16,8 +16,11 @@ use function is_object; use function sprintf; -/** @template-extends AbstractExpressionEncoder */ -class CombinedFieldQueryEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class CombinedFieldQueryEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/DictionaryEncoder.php b/src/Builder/Encoder/DictionaryEncoder.php index 078db76ed..f228fa2d7 100644 --- a/src/Builder/Encoder/DictionaryEncoder.php +++ b/src/Builder/Encoder/DictionaryEncoder.php @@ -9,8 +9,11 @@ use MongoDB\Exception\UnsupportedValueException; use stdClass; -/** @template-extends AbstractExpressionEncoder */ -class DictionaryEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class DictionaryEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/ExpressionEncoder.php b/src/Builder/Encoder/ExpressionEncoder.php index 1fe94790e..b1acab2ee 100644 --- a/src/Builder/Encoder/ExpressionEncoder.php +++ b/src/Builder/Encoder/ExpressionEncoder.php @@ -12,6 +12,7 @@ * @template BSONType of stdClass|array|string|int * @template NativeType * @template-extends Encoder + * @internal */ interface ExpressionEncoder extends Encoder { diff --git a/src/Builder/Encoder/FieldPathEncoder.php b/src/Builder/Encoder/FieldPathEncoder.php index 8fe7381c2..4dc7b6f2c 100644 --- a/src/Builder/Encoder/FieldPathEncoder.php +++ b/src/Builder/Encoder/FieldPathEncoder.php @@ -8,8 +8,11 @@ use MongoDB\Codec\EncodeIfSupported; use MongoDB\Exception\UnsupportedValueException; -/** @template-extends AbstractExpressionEncoder */ -class FieldPathEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class FieldPathEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; @@ -25,7 +28,6 @@ public function encode(mixed $value): string throw UnsupportedValueException::invalidEncodableValue($value); } - // TODO: needs method because interfaces can't have properties return '$' . $value->name; } } diff --git a/src/Builder/Encoder/OperatorEncoder.php b/src/Builder/Encoder/OperatorEncoder.php index 4996c7c3f..ddc49faab 100644 --- a/src/Builder/Encoder/OperatorEncoder.php +++ b/src/Builder/Encoder/OperatorEncoder.php @@ -14,8 +14,11 @@ use function sprintf; -/** @template-extends AbstractExpressionEncoder */ -class OperatorEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class OperatorEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/OutputWindowEncoder.php b/src/Builder/Encoder/OutputWindowEncoder.php index 9db567386..830c2cacb 100644 --- a/src/Builder/Encoder/OutputWindowEncoder.php +++ b/src/Builder/Encoder/OutputWindowEncoder.php @@ -17,8 +17,11 @@ use function MongoDB\is_first_key_operator; use function sprintf; -/** @template-extends AbstractExpressionEncoder */ -class OutputWindowEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class OutputWindowEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/PipelineEncoder.php b/src/Builder/Encoder/PipelineEncoder.php index f0b319e9c..5a343e0fb 100644 --- a/src/Builder/Encoder/PipelineEncoder.php +++ b/src/Builder/Encoder/PipelineEncoder.php @@ -8,8 +8,11 @@ use MongoDB\Codec\EncodeIfSupported; use MongoDB\Exception\UnsupportedValueException; -/** @template-extends AbstractExpressionEncoder, Pipeline> */ -class PipelineEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder, Pipeline> + * @internal + */ +final class PipelineEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported, Pipeline> */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/QueryEncoder.php b/src/Builder/Encoder/QueryEncoder.php index d5890506c..2193edb02 100644 --- a/src/Builder/Encoder/QueryEncoder.php +++ b/src/Builder/Encoder/QueryEncoder.php @@ -15,8 +15,11 @@ use function property_exists; use function sprintf; -/** @template-extends AbstractExpressionEncoder */ -class QueryEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class QueryEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Encoder/VariableEncoder.php b/src/Builder/Encoder/VariableEncoder.php index 726acb9ee..31f73b6d8 100644 --- a/src/Builder/Encoder/VariableEncoder.php +++ b/src/Builder/Encoder/VariableEncoder.php @@ -8,8 +8,11 @@ use MongoDB\Codec\EncodeIfSupported; use MongoDB\Exception\UnsupportedValueException; -/** @template-extends AbstractExpressionEncoder */ -class VariableEncoder extends AbstractExpressionEncoder +/** + * @template-extends AbstractExpressionEncoder + * @internal + */ +final class VariableEncoder extends AbstractExpressionEncoder { /** @template-use EncodeIfSupported */ use EncodeIfSupported; diff --git a/src/Builder/Expression/AbsOperator.php b/src/Builder/Expression/AbsOperator.php index b187d31c2..aa0dfc78a 100644 --- a/src/Builder/Expression/AbsOperator.php +++ b/src/Builder/Expression/AbsOperator.php @@ -17,8 +17,9 @@ * Returns the absolute value of a number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/ + * @internal */ -class AbsOperator implements ResolvesToNumber, OperatorInterface +final class AbsOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Expression/AcosOperator.php b/src/Builder/Expression/AcosOperator.php index 60a30b6d3..7123b7d25 100644 --- a/src/Builder/Expression/AcosOperator.php +++ b/src/Builder/Expression/AcosOperator.php @@ -17,8 +17,9 @@ * Returns the inverse cosine (arc cosine) of a value in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/ + * @internal */ -class AcosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class AcosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AcoshOperator.php b/src/Builder/Expression/AcoshOperator.php index d0cc50c92..1715e3a41 100644 --- a/src/Builder/Expression/AcoshOperator.php +++ b/src/Builder/Expression/AcoshOperator.php @@ -17,8 +17,9 @@ * Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/ + * @internal */ -class AcoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class AcoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AddOperator.php b/src/Builder/Expression/AddOperator.php index 5437e6dac..45e9fa745 100644 --- a/src/Builder/Expression/AddOperator.php +++ b/src/Builder/Expression/AddOperator.php @@ -21,8 +21,9 @@ * Adds numbers to return the sum, or adds numbers and a date to return a new date. If adding numbers and a date, treats the numbers as milliseconds. Accepts any number of argument expressions, but at most, one expression can resolve to a date. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/ + * @internal */ -class AddOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface +final class AddOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AllElementsTrueOperator.php b/src/Builder/Expression/AllElementsTrueOperator.php index 27430149a..4ac75df9a 100644 --- a/src/Builder/Expression/AllElementsTrueOperator.php +++ b/src/Builder/Expression/AllElementsTrueOperator.php @@ -21,8 +21,9 @@ * Returns true if no element of a set evaluates to false, otherwise, returns false. Accepts a single argument expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/ + * @internal */ -class AllElementsTrueOperator implements ResolvesToBool, OperatorInterface +final class AllElementsTrueOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AndOperator.php b/src/Builder/Expression/AndOperator.php index e6bdc6f31..7334967e5 100644 --- a/src/Builder/Expression/AndOperator.php +++ b/src/Builder/Expression/AndOperator.php @@ -23,8 +23,9 @@ * Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ + * @internal */ -class AndOperator implements ResolvesToBool, OperatorInterface +final class AndOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AnyElementTrueOperator.php b/src/Builder/Expression/AnyElementTrueOperator.php index ec80ca8fc..fa0b0a3f7 100644 --- a/src/Builder/Expression/AnyElementTrueOperator.php +++ b/src/Builder/Expression/AnyElementTrueOperator.php @@ -21,8 +21,9 @@ * Returns true if any elements of a set evaluate to true; otherwise, returns false. Accepts a single argument expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/ + * @internal */ -class AnyElementTrueOperator implements ResolvesToBool, OperatorInterface +final class AnyElementTrueOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ArrayElemAtOperator.php b/src/Builder/Expression/ArrayElemAtOperator.php index 32f84ac83..81cc74497 100644 --- a/src/Builder/Expression/ArrayElemAtOperator.php +++ b/src/Builder/Expression/ArrayElemAtOperator.php @@ -21,8 +21,9 @@ * Returns the element at the specified array index. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/ + * @internal */ -class ArrayElemAtOperator implements ResolvesToAny, OperatorInterface +final class ArrayElemAtOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['array' => 'array', 'idx' => 'idx']; diff --git a/src/Builder/Expression/ArrayToObjectOperator.php b/src/Builder/Expression/ArrayToObjectOperator.php index dfaf70002..765923441 100644 --- a/src/Builder/Expression/ArrayToObjectOperator.php +++ b/src/Builder/Expression/ArrayToObjectOperator.php @@ -21,8 +21,9 @@ * Converts an array of key value pairs to a document. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/ + * @internal */ -class ArrayToObjectOperator implements ResolvesToObject, OperatorInterface +final class ArrayToObjectOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['array' => 'array']; diff --git a/src/Builder/Expression/AsinOperator.php b/src/Builder/Expression/AsinOperator.php index e7f144ff9..f9c585980 100644 --- a/src/Builder/Expression/AsinOperator.php +++ b/src/Builder/Expression/AsinOperator.php @@ -17,8 +17,9 @@ * Returns the inverse sin (arc sine) of a value in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/ + * @internal */ -class AsinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class AsinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AsinhOperator.php b/src/Builder/Expression/AsinhOperator.php index e53bacf34..720c5e20e 100644 --- a/src/Builder/Expression/AsinhOperator.php +++ b/src/Builder/Expression/AsinhOperator.php @@ -17,8 +17,9 @@ * Returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/ + * @internal */ -class AsinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class AsinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/Atan2Operator.php b/src/Builder/Expression/Atan2Operator.php index a5bd626f7..ae485c994 100644 --- a/src/Builder/Expression/Atan2Operator.php +++ b/src/Builder/Expression/Atan2Operator.php @@ -17,8 +17,9 @@ * Returns the inverse tangent (arc tangent) of y / x in radians, where y and x are the first and second values passed to the expression respectively. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/ + * @internal */ -class Atan2Operator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class Atan2Operator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['y' => 'y', 'x' => 'x']; diff --git a/src/Builder/Expression/AtanOperator.php b/src/Builder/Expression/AtanOperator.php index a41095dd1..7ba685da0 100644 --- a/src/Builder/Expression/AtanOperator.php +++ b/src/Builder/Expression/AtanOperator.php @@ -17,8 +17,9 @@ * Returns the inverse tangent (arc tangent) of a value in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/ + * @internal */ -class AtanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class AtanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AtanhOperator.php b/src/Builder/Expression/AtanhOperator.php index f1f3ed1a5..ad2ab4df1 100644 --- a/src/Builder/Expression/AtanhOperator.php +++ b/src/Builder/Expression/AtanhOperator.php @@ -17,8 +17,9 @@ * Returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/ + * @internal */ -class AtanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class AtanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/AvgOperator.php b/src/Builder/Expression/AvgOperator.php index 457d3c278..ba6d83fa3 100644 --- a/src/Builder/Expression/AvgOperator.php +++ b/src/Builder/Expression/AvgOperator.php @@ -21,8 +21,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/ + * @internal */ -class AvgOperator implements ResolvesToNumber, OperatorInterface +final class AvgOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/BinarySizeOperator.php b/src/Builder/Expression/BinarySizeOperator.php index 7cb22f5e5..0dfc99fdd 100644 --- a/src/Builder/Expression/BinarySizeOperator.php +++ b/src/Builder/Expression/BinarySizeOperator.php @@ -16,8 +16,9 @@ * Returns the size of a given string or binary data value's content in bytes. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/ + * @internal */ -class BinarySizeOperator implements ResolvesToInt, OperatorInterface +final class BinarySizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/BitAndOperator.php b/src/Builder/Expression/BitAndOperator.php index 09f02b2a6..a66b516d7 100644 --- a/src/Builder/Expression/BitAndOperator.php +++ b/src/Builder/Expression/BitAndOperator.php @@ -20,8 +20,9 @@ * New in MongoDB 6.3. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/ + * @internal */ -class BitAndOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface +final class BitAndOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/BitNotOperator.php b/src/Builder/Expression/BitNotOperator.php index 364c8e982..4acbf652c 100644 --- a/src/Builder/Expression/BitNotOperator.php +++ b/src/Builder/Expression/BitNotOperator.php @@ -17,8 +17,9 @@ * New in MongoDB 6.3. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/ + * @internal */ -class BitNotOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface +final class BitNotOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/BitOrOperator.php b/src/Builder/Expression/BitOrOperator.php index ab5a41a20..db435a710 100644 --- a/src/Builder/Expression/BitOrOperator.php +++ b/src/Builder/Expression/BitOrOperator.php @@ -20,8 +20,9 @@ * New in MongoDB 6.3. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/ + * @internal */ -class BitOrOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface +final class BitOrOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/BitXorOperator.php b/src/Builder/Expression/BitXorOperator.php index fd380961e..6b86ea43f 100644 --- a/src/Builder/Expression/BitXorOperator.php +++ b/src/Builder/Expression/BitXorOperator.php @@ -20,8 +20,9 @@ * New in MongoDB 6.3. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/ + * @internal */ -class BitXorOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface +final class BitXorOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/BsonSizeOperator.php b/src/Builder/Expression/BsonSizeOperator.php index 15105176c..cdf5e27c9 100644 --- a/src/Builder/Expression/BsonSizeOperator.php +++ b/src/Builder/Expression/BsonSizeOperator.php @@ -18,8 +18,9 @@ * Returns the size in bytes of a given document (i.e. BSON type Object) when encoded as BSON. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/ + * @internal */ -class BsonSizeOperator implements ResolvesToInt, OperatorInterface +final class BsonSizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['object' => 'object']; diff --git a/src/Builder/Expression/CaseOperator.php b/src/Builder/Expression/CaseOperator.php index 6f5c293d1..c43db4b7f 100644 --- a/src/Builder/Expression/CaseOperator.php +++ b/src/Builder/Expression/CaseOperator.php @@ -19,8 +19,9 @@ * Represents a single case in a $switch expression * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/ + * @internal */ -class CaseOperator implements SwitchBranchInterface, OperatorInterface +final class CaseOperator implements SwitchBranchInterface, OperatorInterface { public const ENCODE = Encode::FlatObject; public const PROPERTIES = ['case' => 'case', 'then' => 'then']; diff --git a/src/Builder/Expression/CeilOperator.php b/src/Builder/Expression/CeilOperator.php index e6308dee4..e997a5fd8 100644 --- a/src/Builder/Expression/CeilOperator.php +++ b/src/Builder/Expression/CeilOperator.php @@ -17,8 +17,9 @@ * Returns the smallest integer greater than or equal to the specified number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/ + * @internal */ -class CeilOperator implements ResolvesToInt, OperatorInterface +final class CeilOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/CmpOperator.php b/src/Builder/Expression/CmpOperator.php index 41f3636e1..620602680 100644 --- a/src/Builder/Expression/CmpOperator.php +++ b/src/Builder/Expression/CmpOperator.php @@ -18,8 +18,9 @@ * Returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/ + * @internal */ -class CmpOperator implements ResolvesToInt, OperatorInterface +final class CmpOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/ConcatArraysOperator.php b/src/Builder/Expression/ConcatArraysOperator.php index 215d06071..27ad5736c 100644 --- a/src/Builder/Expression/ConcatArraysOperator.php +++ b/src/Builder/Expression/ConcatArraysOperator.php @@ -20,8 +20,9 @@ * Concatenates arrays to return the concatenated array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/ + * @internal */ -class ConcatArraysOperator implements ResolvesToArray, OperatorInterface +final class ConcatArraysOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['array' => 'array']; diff --git a/src/Builder/Expression/ConcatOperator.php b/src/Builder/Expression/ConcatOperator.php index fcec6e26b..c1ac43294 100644 --- a/src/Builder/Expression/ConcatOperator.php +++ b/src/Builder/Expression/ConcatOperator.php @@ -18,8 +18,9 @@ * Concatenates any number of strings. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/ + * @internal */ -class ConcatOperator implements ResolvesToString, OperatorInterface +final class ConcatOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/CondOperator.php b/src/Builder/Expression/CondOperator.php index 67a92f987..97b286e45 100644 --- a/src/Builder/Expression/CondOperator.php +++ b/src/Builder/Expression/CondOperator.php @@ -18,8 +18,9 @@ * A ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions. Accepts either three expressions in an ordered list or three named parameters. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/ + * @internal */ -class CondOperator implements ResolvesToAny, OperatorInterface +final class CondOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['if' => 'if', 'then' => 'then', 'else' => 'else']; diff --git a/src/Builder/Expression/ConvertOperator.php b/src/Builder/Expression/ConvertOperator.php index ee48fb04f..0418c26b9 100644 --- a/src/Builder/Expression/ConvertOperator.php +++ b/src/Builder/Expression/ConvertOperator.php @@ -20,8 +20,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ + * @internal */ -class ConvertOperator implements ResolvesToAny, OperatorInterface +final class ConvertOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'to' => 'to', 'onError' => 'onError', 'onNull' => 'onNull']; diff --git a/src/Builder/Expression/CosOperator.php b/src/Builder/Expression/CosOperator.php index 42657efe2..0b5a2e7e7 100644 --- a/src/Builder/Expression/CosOperator.php +++ b/src/Builder/Expression/CosOperator.php @@ -17,8 +17,9 @@ * Returns the cosine of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/ + * @internal */ -class CosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class CosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/CoshOperator.php b/src/Builder/Expression/CoshOperator.php index f72d1d652..b1a481772 100644 --- a/src/Builder/Expression/CoshOperator.php +++ b/src/Builder/Expression/CoshOperator.php @@ -17,8 +17,9 @@ * Returns the hyperbolic cosine of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/ + * @internal */ -class CoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class CoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/DateAddOperator.php b/src/Builder/Expression/DateAddOperator.php index 3032f0134..208a1e4dc 100644 --- a/src/Builder/Expression/DateAddOperator.php +++ b/src/Builder/Expression/DateAddOperator.php @@ -21,8 +21,9 @@ * Adds a number of time units to a date object. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/ + * @internal */ -class DateAddOperator implements ResolvesToDate, OperatorInterface +final class DateAddOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['startDate' => 'startDate', 'unit' => 'unit', 'amount' => 'amount', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/DateDiffOperator.php b/src/Builder/Expression/DateDiffOperator.php index 482c1d830..67b2bfc2f 100644 --- a/src/Builder/Expression/DateDiffOperator.php +++ b/src/Builder/Expression/DateDiffOperator.php @@ -20,8 +20,9 @@ * Returns the difference between two dates. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/ + * @internal */ -class DateDiffOperator implements ResolvesToInt, OperatorInterface +final class DateDiffOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Expression/DateFromPartsOperator.php b/src/Builder/Expression/DateFromPartsOperator.php index 1716b93e7..1cd5cd678 100644 --- a/src/Builder/Expression/DateFromPartsOperator.php +++ b/src/Builder/Expression/DateFromPartsOperator.php @@ -18,8 +18,9 @@ * Constructs a BSON Date object given the date's constituent parts. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/ + * @internal */ -class DateFromPartsOperator implements ResolvesToDate, OperatorInterface +final class DateFromPartsOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Expression/DateFromStringOperator.php b/src/Builder/Expression/DateFromStringOperator.php index 493914b72..0d35eb7b3 100644 --- a/src/Builder/Expression/DateFromStringOperator.php +++ b/src/Builder/Expression/DateFromStringOperator.php @@ -19,8 +19,9 @@ * Converts a date/time string to a date object. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/ + * @internal */ -class DateFromStringOperator implements ResolvesToDate, OperatorInterface +final class DateFromStringOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Expression/DateSubtractOperator.php b/src/Builder/Expression/DateSubtractOperator.php index 2354e2257..4112ded11 100644 --- a/src/Builder/Expression/DateSubtractOperator.php +++ b/src/Builder/Expression/DateSubtractOperator.php @@ -21,8 +21,9 @@ * Subtracts a number of time units from a date object. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/ + * @internal */ -class DateSubtractOperator implements ResolvesToDate, OperatorInterface +final class DateSubtractOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['startDate' => 'startDate', 'unit' => 'unit', 'amount' => 'amount', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/DateToPartsOperator.php b/src/Builder/Expression/DateToPartsOperator.php index 0b750653d..1d8754a4d 100644 --- a/src/Builder/Expression/DateToPartsOperator.php +++ b/src/Builder/Expression/DateToPartsOperator.php @@ -19,8 +19,9 @@ * Returns a document containing the constituent parts of a date. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/ + * @internal */ -class DateToPartsOperator implements ResolvesToObject, OperatorInterface +final class DateToPartsOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone', 'iso8601' => 'iso8601']; diff --git a/src/Builder/Expression/DateToStringOperator.php b/src/Builder/Expression/DateToStringOperator.php index 5950592bc..d1403f67c 100644 --- a/src/Builder/Expression/DateToStringOperator.php +++ b/src/Builder/Expression/DateToStringOperator.php @@ -22,8 +22,9 @@ * Returns the date as a formatted string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/ + * @internal */ -class DateToStringOperator implements ResolvesToString, OperatorInterface +final class DateToStringOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'format' => 'format', 'timezone' => 'timezone', 'onNull' => 'onNull']; diff --git a/src/Builder/Expression/DateTruncOperator.php b/src/Builder/Expression/DateTruncOperator.php index 2a535fab6..643cd3a7f 100644 --- a/src/Builder/Expression/DateTruncOperator.php +++ b/src/Builder/Expression/DateTruncOperator.php @@ -22,8 +22,9 @@ * Truncates a date. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/ + * @internal */ -class DateTruncOperator implements ResolvesToDate, OperatorInterface +final class DateTruncOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Expression/DayOfMonthOperator.php b/src/Builder/Expression/DayOfMonthOperator.php index ed455bfd3..1d336d692 100644 --- a/src/Builder/Expression/DayOfMonthOperator.php +++ b/src/Builder/Expression/DayOfMonthOperator.php @@ -19,8 +19,9 @@ * Returns the day of the month for a date as a number between 1 and 31. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/ + * @internal */ -class DayOfMonthOperator implements ResolvesToInt, OperatorInterface +final class DayOfMonthOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/DayOfWeekOperator.php b/src/Builder/Expression/DayOfWeekOperator.php index b3bc1f58f..51e296d73 100644 --- a/src/Builder/Expression/DayOfWeekOperator.php +++ b/src/Builder/Expression/DayOfWeekOperator.php @@ -19,8 +19,9 @@ * Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/ + * @internal */ -class DayOfWeekOperator implements ResolvesToInt, OperatorInterface +final class DayOfWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/DayOfYearOperator.php b/src/Builder/Expression/DayOfYearOperator.php index a7f38720a..febb353a5 100644 --- a/src/Builder/Expression/DayOfYearOperator.php +++ b/src/Builder/Expression/DayOfYearOperator.php @@ -19,8 +19,9 @@ * Returns the day of the year for a date as a number between 1 and 366 (leap year). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/ + * @internal */ -class DayOfYearOperator implements ResolvesToInt, OperatorInterface +final class DayOfYearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/DegreesToRadiansOperator.php b/src/Builder/Expression/DegreesToRadiansOperator.php index b38a82c74..412a49791 100644 --- a/src/Builder/Expression/DegreesToRadiansOperator.php +++ b/src/Builder/Expression/DegreesToRadiansOperator.php @@ -17,8 +17,9 @@ * Converts a value from degrees to radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/ + * @internal */ -class DegreesToRadiansOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class DegreesToRadiansOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/DivideOperator.php b/src/Builder/Expression/DivideOperator.php index 36164e985..79962ca25 100644 --- a/src/Builder/Expression/DivideOperator.php +++ b/src/Builder/Expression/DivideOperator.php @@ -17,8 +17,9 @@ * Returns the result of dividing the first number by the second. Accepts two argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/ + * @internal */ -class DivideOperator implements ResolvesToDouble, OperatorInterface +final class DivideOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['dividend' => 'dividend', 'divisor' => 'divisor']; diff --git a/src/Builder/Expression/EqOperator.php b/src/Builder/Expression/EqOperator.php index f87e35c85..7717ad6d3 100644 --- a/src/Builder/Expression/EqOperator.php +++ b/src/Builder/Expression/EqOperator.php @@ -18,8 +18,9 @@ * Returns true if the values are equivalent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/ + * @internal */ -class EqOperator implements ResolvesToBool, OperatorInterface +final class EqOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/ExpOperator.php b/src/Builder/Expression/ExpOperator.php index 6c9053625..ad37f8365 100644 --- a/src/Builder/Expression/ExpOperator.php +++ b/src/Builder/Expression/ExpOperator.php @@ -17,8 +17,9 @@ * Raises e to the specified exponent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/ + * @internal */ -class ExpOperator implements ResolvesToDouble, OperatorInterface +final class ExpOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['exponent' => 'exponent']; diff --git a/src/Builder/Expression/FilterOperator.php b/src/Builder/Expression/FilterOperator.php index 4ca176f90..665e196e7 100644 --- a/src/Builder/Expression/FilterOperator.php +++ b/src/Builder/Expression/FilterOperator.php @@ -22,8 +22,9 @@ * Selects a subset of the array to return an array with only the elements that match the filter condition. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/ + * @internal */ -class FilterOperator implements ResolvesToArray, OperatorInterface +final class FilterOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'cond' => 'cond', 'as' => 'as', 'limit' => 'limit']; diff --git a/src/Builder/Expression/FirstNOperator.php b/src/Builder/Expression/FirstNOperator.php index e999ec479..c8276f33c 100644 --- a/src/Builder/Expression/FirstNOperator.php +++ b/src/Builder/Expression/FirstNOperator.php @@ -21,8 +21,9 @@ * Returns a specified number of elements from the beginning of an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/ + * @internal */ -class FirstNOperator implements ResolvesToArray, OperatorInterface +final class FirstNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['n' => 'n', 'input' => 'input']; diff --git a/src/Builder/Expression/FirstOperator.php b/src/Builder/Expression/FirstOperator.php index cf4b807da..318dc4769 100644 --- a/src/Builder/Expression/FirstOperator.php +++ b/src/Builder/Expression/FirstOperator.php @@ -21,8 +21,9 @@ * Returns the result of an expression for the first document in an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/ + * @internal */ -class FirstOperator implements ResolvesToAny, OperatorInterface +final class FirstOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/FloorOperator.php b/src/Builder/Expression/FloorOperator.php index 015adb45e..ec974417c 100644 --- a/src/Builder/Expression/FloorOperator.php +++ b/src/Builder/Expression/FloorOperator.php @@ -17,8 +17,9 @@ * Returns the largest integer less than or equal to the specified number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/ + * @internal */ -class FloorOperator implements ResolvesToInt, OperatorInterface +final class FloorOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/FunctionOperator.php b/src/Builder/Expression/FunctionOperator.php index c06790010..6b9d1ba8a 100644 --- a/src/Builder/Expression/FunctionOperator.php +++ b/src/Builder/Expression/FunctionOperator.php @@ -24,8 +24,9 @@ * New in MongoDB 4.4. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ + * @internal */ -class FunctionOperator implements ResolvesToAny, OperatorInterface +final class FunctionOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['body' => 'body', 'args' => 'args', 'lang' => 'lang']; diff --git a/src/Builder/Expression/GetFieldOperator.php b/src/Builder/Expression/GetFieldOperator.php index 8a0efe6a4..188c074fe 100644 --- a/src/Builder/Expression/GetFieldOperator.php +++ b/src/Builder/Expression/GetFieldOperator.php @@ -20,8 +20,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/ + * @internal */ -class GetFieldOperator implements ResolvesToAny, OperatorInterface +final class GetFieldOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['field' => 'field', 'input' => 'input']; diff --git a/src/Builder/Expression/GtOperator.php b/src/Builder/Expression/GtOperator.php index 27c66ecee..badb0b951 100644 --- a/src/Builder/Expression/GtOperator.php +++ b/src/Builder/Expression/GtOperator.php @@ -18,8 +18,9 @@ * Returns true if the first value is greater than the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/ + * @internal */ -class GtOperator implements ResolvesToBool, OperatorInterface +final class GtOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/GteOperator.php b/src/Builder/Expression/GteOperator.php index d3a37100b..45931a7ae 100644 --- a/src/Builder/Expression/GteOperator.php +++ b/src/Builder/Expression/GteOperator.php @@ -18,8 +18,9 @@ * Returns true if the first value is greater than or equal to the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/ + * @internal */ -class GteOperator implements ResolvesToBool, OperatorInterface +final class GteOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/HourOperator.php b/src/Builder/Expression/HourOperator.php index f13dce737..47d7ba339 100644 --- a/src/Builder/Expression/HourOperator.php +++ b/src/Builder/Expression/HourOperator.php @@ -19,8 +19,9 @@ * Returns the hour for a date as a number between 0 and 23. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/ + * @internal */ -class HourOperator implements ResolvesToInt, OperatorInterface +final class HourOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/IfNullOperator.php b/src/Builder/Expression/IfNullOperator.php index 60cb20a71..06a7926a4 100644 --- a/src/Builder/Expression/IfNullOperator.php +++ b/src/Builder/Expression/IfNullOperator.php @@ -21,8 +21,9 @@ * Returns either the non-null result of the first expression or the result of the second expression if the first expression results in a null result. Null result encompasses instances of undefined values or missing fields. Accepts two expressions as arguments. The result of the second expression can be null. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/ + * @internal */ -class IfNullOperator implements ResolvesToAny, OperatorInterface +final class IfNullOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/InOperator.php b/src/Builder/Expression/InOperator.php index a16badda9..31d78bb26 100644 --- a/src/Builder/Expression/InOperator.php +++ b/src/Builder/Expression/InOperator.php @@ -24,8 +24,9 @@ * Returns a boolean indicating whether a specified value is in an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/ + * @internal */ -class InOperator implements ResolvesToBool, OperatorInterface +final class InOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression' => 'expression', 'array' => 'array']; diff --git a/src/Builder/Expression/IndexOfArrayOperator.php b/src/Builder/Expression/IndexOfArrayOperator.php index ac9eaef94..912e20a86 100644 --- a/src/Builder/Expression/IndexOfArrayOperator.php +++ b/src/Builder/Expression/IndexOfArrayOperator.php @@ -25,8 +25,9 @@ * Searches an array for an occurrence of a specified value and returns the array index of the first occurrence. Array indexes start at zero. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/ + * @internal */ -class IndexOfArrayOperator implements ResolvesToInt, OperatorInterface +final class IndexOfArrayOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['array' => 'array', 'search' => 'search', 'start' => 'start', 'end' => 'end']; diff --git a/src/Builder/Expression/IndexOfBytesOperator.php b/src/Builder/Expression/IndexOfBytesOperator.php index e77706a5c..788b4ecb9 100644 --- a/src/Builder/Expression/IndexOfBytesOperator.php +++ b/src/Builder/Expression/IndexOfBytesOperator.php @@ -16,8 +16,9 @@ * Searches a string for an occurrence of a substring and returns the UTF-8 byte index of the first occurrence. If the substring is not found, returns -1. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/ + * @internal */ -class IndexOfBytesOperator implements ResolvesToInt, OperatorInterface +final class IndexOfBytesOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['string' => 'string', 'substring' => 'substring', 'start' => 'start', 'end' => 'end']; diff --git a/src/Builder/Expression/IndexOfCPOperator.php b/src/Builder/Expression/IndexOfCPOperator.php index 3542a7f8d..076b7747c 100644 --- a/src/Builder/Expression/IndexOfCPOperator.php +++ b/src/Builder/Expression/IndexOfCPOperator.php @@ -16,8 +16,9 @@ * Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurrence. If the substring is not found, returns -1 * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/ + * @internal */ -class IndexOfCPOperator implements ResolvesToInt, OperatorInterface +final class IndexOfCPOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['string' => 'string', 'substring' => 'substring', 'start' => 'start', 'end' => 'end']; diff --git a/src/Builder/Expression/IsArrayOperator.php b/src/Builder/Expression/IsArrayOperator.php index 81fce561e..7a8329acb 100644 --- a/src/Builder/Expression/IsArrayOperator.php +++ b/src/Builder/Expression/IsArrayOperator.php @@ -18,8 +18,9 @@ * Determines if the operand is an array. Returns a boolean. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/ + * @internal */ -class IsArrayOperator implements ResolvesToBool, OperatorInterface +final class IsArrayOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/IsNumberOperator.php b/src/Builder/Expression/IsNumberOperator.php index a8586a21c..65a94800b 100644 --- a/src/Builder/Expression/IsNumberOperator.php +++ b/src/Builder/Expression/IsNumberOperator.php @@ -20,8 +20,9 @@ * New in MongoDB 4.4. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/ + * @internal */ -class IsNumberOperator implements ResolvesToBool, OperatorInterface +final class IsNumberOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/IsoDayOfWeekOperator.php b/src/Builder/Expression/IsoDayOfWeekOperator.php index fdfdd74cb..68eb77cc2 100644 --- a/src/Builder/Expression/IsoDayOfWeekOperator.php +++ b/src/Builder/Expression/IsoDayOfWeekOperator.php @@ -19,8 +19,9 @@ * Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/ + * @internal */ -class IsoDayOfWeekOperator implements ResolvesToInt, OperatorInterface +final class IsoDayOfWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/IsoWeekOperator.php b/src/Builder/Expression/IsoWeekOperator.php index 8801293fd..b86fa89cf 100644 --- a/src/Builder/Expression/IsoWeekOperator.php +++ b/src/Builder/Expression/IsoWeekOperator.php @@ -19,8 +19,9 @@ * Returns the week number in ISO 8601 format, ranging from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year's first Thursday. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/ + * @internal */ -class IsoWeekOperator implements ResolvesToInt, OperatorInterface +final class IsoWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/IsoWeekYearOperator.php b/src/Builder/Expression/IsoWeekYearOperator.php index 946be3836..a9df2dc4f 100644 --- a/src/Builder/Expression/IsoWeekYearOperator.php +++ b/src/Builder/Expression/IsoWeekYearOperator.php @@ -19,8 +19,9 @@ * Returns the year number in ISO 8601 format. The year starts with the Monday of week 1 (ISO 8601) and ends with the Sunday of the last week (ISO 8601). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/ + * @internal */ -class IsoWeekYearOperator implements ResolvesToInt, OperatorInterface +final class IsoWeekYearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/LastNOperator.php b/src/Builder/Expression/LastNOperator.php index 9e820061f..fe6c65110 100644 --- a/src/Builder/Expression/LastNOperator.php +++ b/src/Builder/Expression/LastNOperator.php @@ -21,8 +21,9 @@ * Returns a specified number of elements from the end of an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN-array-element/ + * @internal */ -class LastNOperator implements ResolvesToArray, OperatorInterface +final class LastNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['n' => 'n', 'input' => 'input']; diff --git a/src/Builder/Expression/LastOperator.php b/src/Builder/Expression/LastOperator.php index a8ba3ed16..28b913c3b 100644 --- a/src/Builder/Expression/LastOperator.php +++ b/src/Builder/Expression/LastOperator.php @@ -21,8 +21,9 @@ * Returns the result of an expression for the last document in an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ + * @internal */ -class LastOperator implements ResolvesToAny, OperatorInterface +final class LastOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/LetOperator.php b/src/Builder/Expression/LetOperator.php index 0e9ead011..41d9428ff 100644 --- a/src/Builder/Expression/LetOperator.php +++ b/src/Builder/Expression/LetOperator.php @@ -21,8 +21,9 @@ * Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/ + * @internal */ -class LetOperator implements ResolvesToAny, OperatorInterface +final class LetOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['vars' => 'vars', 'in' => 'in']; diff --git a/src/Builder/Expression/LiteralOperator.php b/src/Builder/Expression/LiteralOperator.php index 9f56638a8..be1d2e0d4 100644 --- a/src/Builder/Expression/LiteralOperator.php +++ b/src/Builder/Expression/LiteralOperator.php @@ -17,8 +17,9 @@ * Return a value without parsing. Use for values that the aggregation pipeline may interpret as an expression. For example, use a $literal expression to a string that starts with a dollar sign ($) to avoid parsing as a field path. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ + * @internal */ -class LiteralOperator implements ResolvesToAny, OperatorInterface +final class LiteralOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Expression/LnOperator.php b/src/Builder/Expression/LnOperator.php index ca6977fb7..a62a522b8 100644 --- a/src/Builder/Expression/LnOperator.php +++ b/src/Builder/Expression/LnOperator.php @@ -18,8 +18,9 @@ * $ln is equivalent to $log: [ , Math.E ] expression, where Math.E is a JavaScript representation for Euler's number e. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/ + * @internal */ -class LnOperator implements ResolvesToDouble, OperatorInterface +final class LnOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['number' => 'number']; diff --git a/src/Builder/Expression/Log10Operator.php b/src/Builder/Expression/Log10Operator.php index d7b9c83b2..ed097e9a6 100644 --- a/src/Builder/Expression/Log10Operator.php +++ b/src/Builder/Expression/Log10Operator.php @@ -17,8 +17,9 @@ * Calculates the log base 10 of a number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/ + * @internal */ -class Log10Operator implements ResolvesToDouble, OperatorInterface +final class Log10Operator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['number' => 'number']; diff --git a/src/Builder/Expression/LogOperator.php b/src/Builder/Expression/LogOperator.php index 6ff8bcdc1..8bd2067f9 100644 --- a/src/Builder/Expression/LogOperator.php +++ b/src/Builder/Expression/LogOperator.php @@ -17,8 +17,9 @@ * Calculates the log of a number in the specified base. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/ + * @internal */ -class LogOperator implements ResolvesToDouble, OperatorInterface +final class LogOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['number' => 'number', 'base' => 'base']; diff --git a/src/Builder/Expression/LtOperator.php b/src/Builder/Expression/LtOperator.php index b8c47aef3..0dab045fc 100644 --- a/src/Builder/Expression/LtOperator.php +++ b/src/Builder/Expression/LtOperator.php @@ -18,8 +18,9 @@ * Returns true if the first value is less than the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/ + * @internal */ -class LtOperator implements ResolvesToBool, OperatorInterface +final class LtOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/LteOperator.php b/src/Builder/Expression/LteOperator.php index 13843dc36..2358b2cab 100644 --- a/src/Builder/Expression/LteOperator.php +++ b/src/Builder/Expression/LteOperator.php @@ -18,8 +18,9 @@ * Returns true if the first value is less than or equal to the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/ + * @internal */ -class LteOperator implements ResolvesToBool, OperatorInterface +final class LteOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/LtrimOperator.php b/src/Builder/Expression/LtrimOperator.php index 1a2027753..6327a5529 100644 --- a/src/Builder/Expression/LtrimOperator.php +++ b/src/Builder/Expression/LtrimOperator.php @@ -17,8 +17,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/ + * @internal */ -class LtrimOperator implements ResolvesToString, OperatorInterface +final class LtrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'chars' => 'chars']; diff --git a/src/Builder/Expression/MapOperator.php b/src/Builder/Expression/MapOperator.php index 35ddc7d01..1fd98300b 100644 --- a/src/Builder/Expression/MapOperator.php +++ b/src/Builder/Expression/MapOperator.php @@ -25,8 +25,9 @@ * Applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/ + * @internal */ -class MapOperator implements ResolvesToArray, OperatorInterface +final class MapOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'in' => 'in', 'as' => 'as']; diff --git a/src/Builder/Expression/MaxNOperator.php b/src/Builder/Expression/MaxNOperator.php index bf07fec41..11dd0ba66 100644 --- a/src/Builder/Expression/MaxNOperator.php +++ b/src/Builder/Expression/MaxNOperator.php @@ -21,8 +21,9 @@ * Returns the n largest values in an array. Distinct from the $maxN accumulator. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/ + * @internal */ -class MaxNOperator implements ResolvesToArray, OperatorInterface +final class MaxNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'n' => 'n']; diff --git a/src/Builder/Expression/MaxOperator.php b/src/Builder/Expression/MaxOperator.php index a04e56281..fee83dcdc 100644 --- a/src/Builder/Expression/MaxOperator.php +++ b/src/Builder/Expression/MaxOperator.php @@ -22,8 +22,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/ + * @internal */ -class MaxOperator implements ResolvesToAny, OperatorInterface +final class MaxOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/MedianOperator.php b/src/Builder/Expression/MedianOperator.php index 1432737a3..3591950bf 100644 --- a/src/Builder/Expression/MedianOperator.php +++ b/src/Builder/Expression/MedianOperator.php @@ -28,8 +28,9 @@ * It is also available as an aggregation expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/ + * @internal */ -class MedianOperator implements ResolvesToDouble, OperatorInterface +final class MedianOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'method' => 'method']; diff --git a/src/Builder/Expression/MergeObjectsOperator.php b/src/Builder/Expression/MergeObjectsOperator.php index d92390760..b5f001971 100644 --- a/src/Builder/Expression/MergeObjectsOperator.php +++ b/src/Builder/Expression/MergeObjectsOperator.php @@ -21,8 +21,9 @@ * Combines multiple documents into a single document. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/ + * @internal */ -class MergeObjectsOperator implements ResolvesToObject, OperatorInterface +final class MergeObjectsOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['document' => 'document']; diff --git a/src/Builder/Expression/MetaOperator.php b/src/Builder/Expression/MetaOperator.php index ab39b4267..f42068b8a 100644 --- a/src/Builder/Expression/MetaOperator.php +++ b/src/Builder/Expression/MetaOperator.php @@ -15,8 +15,9 @@ * Access available per-document metadata related to the aggregation operation. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/ + * @internal */ -class MetaOperator implements ResolvesToAny, OperatorInterface +final class MetaOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['keyword' => 'keyword']; diff --git a/src/Builder/Expression/MillisecondOperator.php b/src/Builder/Expression/MillisecondOperator.php index 9e111e800..3d229a3d8 100644 --- a/src/Builder/Expression/MillisecondOperator.php +++ b/src/Builder/Expression/MillisecondOperator.php @@ -19,8 +19,9 @@ * Returns the milliseconds of a date as a number between 0 and 999. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/ + * @internal */ -class MillisecondOperator implements ResolvesToInt, OperatorInterface +final class MillisecondOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/MinNOperator.php b/src/Builder/Expression/MinNOperator.php index a2bb782bf..a6bff71ef 100644 --- a/src/Builder/Expression/MinNOperator.php +++ b/src/Builder/Expression/MinNOperator.php @@ -21,8 +21,9 @@ * Returns the n smallest values in an array. Distinct from the $minN accumulator. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/ + * @internal */ -class MinNOperator implements ResolvesToArray, OperatorInterface +final class MinNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'n' => 'n']; diff --git a/src/Builder/Expression/MinOperator.php b/src/Builder/Expression/MinOperator.php index 23fa3a5c1..95b609128 100644 --- a/src/Builder/Expression/MinOperator.php +++ b/src/Builder/Expression/MinOperator.php @@ -22,8 +22,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/ + * @internal */ -class MinOperator implements ResolvesToAny, OperatorInterface +final class MinOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/MinuteOperator.php b/src/Builder/Expression/MinuteOperator.php index 494b2c061..d8eed1272 100644 --- a/src/Builder/Expression/MinuteOperator.php +++ b/src/Builder/Expression/MinuteOperator.php @@ -19,8 +19,9 @@ * Returns the minute for a date as a number between 0 and 59. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/ + * @internal */ -class MinuteOperator implements ResolvesToInt, OperatorInterface +final class MinuteOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/ModOperator.php b/src/Builder/Expression/ModOperator.php index bf0565c6e..477828530 100644 --- a/src/Builder/Expression/ModOperator.php +++ b/src/Builder/Expression/ModOperator.php @@ -17,8 +17,9 @@ * Returns the remainder of the first number divided by the second. Accepts two argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/ + * @internal */ -class ModOperator implements ResolvesToInt, OperatorInterface +final class ModOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['dividend' => 'dividend', 'divisor' => 'divisor']; diff --git a/src/Builder/Expression/MonthOperator.php b/src/Builder/Expression/MonthOperator.php index 2ea56f1b1..e11d65ebc 100644 --- a/src/Builder/Expression/MonthOperator.php +++ b/src/Builder/Expression/MonthOperator.php @@ -19,8 +19,9 @@ * Returns the month for a date as a number between 1 (January) and 12 (December). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/ + * @internal */ -class MonthOperator implements ResolvesToInt, OperatorInterface +final class MonthOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/MultiplyOperator.php b/src/Builder/Expression/MultiplyOperator.php index 8cf1d6814..609c5bb76 100644 --- a/src/Builder/Expression/MultiplyOperator.php +++ b/src/Builder/Expression/MultiplyOperator.php @@ -20,8 +20,9 @@ * Multiplies numbers to return the product. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/ + * @internal */ -class MultiplyOperator implements ResolvesToDecimal, OperatorInterface +final class MultiplyOperator implements ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/NeOperator.php b/src/Builder/Expression/NeOperator.php index 935a9e919..ed8a4e423 100644 --- a/src/Builder/Expression/NeOperator.php +++ b/src/Builder/Expression/NeOperator.php @@ -18,8 +18,9 @@ * Returns true if the values are not equivalent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/ + * @internal */ -class NeOperator implements ResolvesToBool, OperatorInterface +final class NeOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/NotOperator.php b/src/Builder/Expression/NotOperator.php index 1849be93b..2b3b0c024 100644 --- a/src/Builder/Expression/NotOperator.php +++ b/src/Builder/Expression/NotOperator.php @@ -18,8 +18,9 @@ * Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/ + * @internal */ -class NotOperator implements ResolvesToBool, OperatorInterface +final class NotOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ObjectToArrayOperator.php b/src/Builder/Expression/ObjectToArrayOperator.php index 67a363a10..6ca01f39b 100644 --- a/src/Builder/Expression/ObjectToArrayOperator.php +++ b/src/Builder/Expression/ObjectToArrayOperator.php @@ -18,8 +18,9 @@ * Converts a document to an array of documents representing key-value pairs. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/ + * @internal */ -class ObjectToArrayOperator implements ResolvesToArray, OperatorInterface +final class ObjectToArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['object' => 'object']; diff --git a/src/Builder/Expression/OrOperator.php b/src/Builder/Expression/OrOperator.php index b112c3307..85447a484 100644 --- a/src/Builder/Expression/OrOperator.php +++ b/src/Builder/Expression/OrOperator.php @@ -21,8 +21,9 @@ * Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/ + * @internal */ -class OrOperator implements ResolvesToBool, OperatorInterface +final class OrOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/PercentileOperator.php b/src/Builder/Expression/PercentileOperator.php index 3f58d1e37..fad9e64e5 100644 --- a/src/Builder/Expression/PercentileOperator.php +++ b/src/Builder/Expression/PercentileOperator.php @@ -31,8 +31,9 @@ * It is also available as an aggregation expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/ + * @internal */ -class PercentileOperator implements ResolvesToArray, OperatorInterface +final class PercentileOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'p' => 'p', 'method' => 'method']; diff --git a/src/Builder/Expression/PowOperator.php b/src/Builder/Expression/PowOperator.php index cac6d4caf..cc6ecdd4f 100644 --- a/src/Builder/Expression/PowOperator.php +++ b/src/Builder/Expression/PowOperator.php @@ -17,8 +17,9 @@ * Raises a number to the specified exponent. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/ + * @internal */ -class PowOperator implements ResolvesToNumber, OperatorInterface +final class PowOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['number' => 'number', 'exponent' => 'exponent']; diff --git a/src/Builder/Expression/RadiansToDegreesOperator.php b/src/Builder/Expression/RadiansToDegreesOperator.php index b1c68424f..60717f251 100644 --- a/src/Builder/Expression/RadiansToDegreesOperator.php +++ b/src/Builder/Expression/RadiansToDegreesOperator.php @@ -17,8 +17,9 @@ * Converts a value from radians to degrees. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/ + * @internal */ -class RadiansToDegreesOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class RadiansToDegreesOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/RandOperator.php b/src/Builder/Expression/RandOperator.php index dd52b877a..02c41c805 100644 --- a/src/Builder/Expression/RandOperator.php +++ b/src/Builder/Expression/RandOperator.php @@ -15,8 +15,9 @@ * Returns a random float between 0 and 1 * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/ + * @internal */ -class RandOperator implements ResolvesToDouble, OperatorInterface +final class RandOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Expression/RangeOperator.php b/src/Builder/Expression/RangeOperator.php index 46decaa42..86f638554 100644 --- a/src/Builder/Expression/RangeOperator.php +++ b/src/Builder/Expression/RangeOperator.php @@ -16,8 +16,9 @@ * Outputs an array containing a sequence of integers according to user-defined inputs. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/ + * @internal */ -class RangeOperator implements ResolvesToArray, OperatorInterface +final class RangeOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['start' => 'start', 'end' => 'end', 'step' => 'step']; diff --git a/src/Builder/Expression/ReduceOperator.php b/src/Builder/Expression/ReduceOperator.php index b0849f2ef..2652e5501 100644 --- a/src/Builder/Expression/ReduceOperator.php +++ b/src/Builder/Expression/ReduceOperator.php @@ -24,8 +24,9 @@ * Applies an expression to each element in an array and combines them into a single value. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/ + * @internal */ -class ReduceOperator implements ResolvesToAny, OperatorInterface +final class ReduceOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'initialValue' => 'initialValue', 'in' => 'in']; diff --git a/src/Builder/Expression/RegexFindAllOperator.php b/src/Builder/Expression/RegexFindAllOperator.php index 221306d68..20cdc69ae 100644 --- a/src/Builder/Expression/RegexFindAllOperator.php +++ b/src/Builder/Expression/RegexFindAllOperator.php @@ -18,8 +18,9 @@ * New in MongoDB 4.2. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/ + * @internal */ -class RegexFindAllOperator implements ResolvesToArray, OperatorInterface +final class RegexFindAllOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'regex' => 'regex', 'options' => 'options']; diff --git a/src/Builder/Expression/RegexFindOperator.php b/src/Builder/Expression/RegexFindOperator.php index 96e7cb368..ff6baa3d1 100644 --- a/src/Builder/Expression/RegexFindOperator.php +++ b/src/Builder/Expression/RegexFindOperator.php @@ -18,8 +18,9 @@ * New in MongoDB 4.2. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/ + * @internal */ -class RegexFindOperator implements ResolvesToObject, OperatorInterface +final class RegexFindOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'regex' => 'regex', 'options' => 'options']; diff --git a/src/Builder/Expression/RegexMatchOperator.php b/src/Builder/Expression/RegexMatchOperator.php index 6d6c039fc..71c246fcc 100644 --- a/src/Builder/Expression/RegexMatchOperator.php +++ b/src/Builder/Expression/RegexMatchOperator.php @@ -18,8 +18,9 @@ * New in MongoDB 4.2. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/ + * @internal */ -class RegexMatchOperator implements ResolvesToBool, OperatorInterface +final class RegexMatchOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'regex' => 'regex', 'options' => 'options']; diff --git a/src/Builder/Expression/ReplaceAllOperator.php b/src/Builder/Expression/ReplaceAllOperator.php index 60f71fbee..29a57e282 100644 --- a/src/Builder/Expression/ReplaceAllOperator.php +++ b/src/Builder/Expression/ReplaceAllOperator.php @@ -17,8 +17,9 @@ * New in MongoDB 4.4. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/ + * @internal */ -class ReplaceAllOperator implements ResolvesToString, OperatorInterface +final class ReplaceAllOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'find' => 'find', 'replacement' => 'replacement']; diff --git a/src/Builder/Expression/ReplaceOneOperator.php b/src/Builder/Expression/ReplaceOneOperator.php index 570bd2d72..c16ae80bd 100644 --- a/src/Builder/Expression/ReplaceOneOperator.php +++ b/src/Builder/Expression/ReplaceOneOperator.php @@ -16,8 +16,9 @@ * New in MongoDB 4.4. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/ + * @internal */ -class ReplaceOneOperator implements ResolvesToString, OperatorInterface +final class ReplaceOneOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'find' => 'find', 'replacement' => 'replacement']; diff --git a/src/Builder/Expression/ReverseArrayOperator.php b/src/Builder/Expression/ReverseArrayOperator.php index ab693e5cd..01a22410d 100644 --- a/src/Builder/Expression/ReverseArrayOperator.php +++ b/src/Builder/Expression/ReverseArrayOperator.php @@ -21,8 +21,9 @@ * Returns an array with the elements in reverse order. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/ + * @internal */ -class ReverseArrayOperator implements ResolvesToArray, OperatorInterface +final class ReverseArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/RoundOperator.php b/src/Builder/Expression/RoundOperator.php index 525900b5e..6df8dfdfc 100644 --- a/src/Builder/Expression/RoundOperator.php +++ b/src/Builder/Expression/RoundOperator.php @@ -18,8 +18,9 @@ * Rounds a number to a whole integer or to a specified decimal place. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/ + * @internal */ -class RoundOperator implements ResolvesToInt, ResolvesToDouble, ResolvesToDecimal, ResolvesToLong, OperatorInterface +final class RoundOperator implements ResolvesToInt, ResolvesToDouble, ResolvesToDecimal, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['number' => 'number', 'place' => 'place']; diff --git a/src/Builder/Expression/RtrimOperator.php b/src/Builder/Expression/RtrimOperator.php index 13ad7cfea..b48272947 100644 --- a/src/Builder/Expression/RtrimOperator.php +++ b/src/Builder/Expression/RtrimOperator.php @@ -16,8 +16,9 @@ * Removes whitespace characters, including null, or the specified characters from the end of a string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/ + * @internal */ -class RtrimOperator implements ResolvesToString, OperatorInterface +final class RtrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'chars' => 'chars']; diff --git a/src/Builder/Expression/SecondOperator.php b/src/Builder/Expression/SecondOperator.php index a2a676518..63df33467 100644 --- a/src/Builder/Expression/SecondOperator.php +++ b/src/Builder/Expression/SecondOperator.php @@ -19,8 +19,9 @@ * Returns the seconds for a date as a number between 0 and 60 (leap seconds). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/ + * @internal */ -class SecondOperator implements ResolvesToInt, OperatorInterface +final class SecondOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/SetDifferenceOperator.php b/src/Builder/Expression/SetDifferenceOperator.php index 58b9ac9f9..f340c3668 100644 --- a/src/Builder/Expression/SetDifferenceOperator.php +++ b/src/Builder/Expression/SetDifferenceOperator.php @@ -21,8 +21,9 @@ * Returns a set with elements that appear in the first set but not in the second set; i.e. performs a relative complement of the second set relative to the first. Accepts exactly two argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/ + * @internal */ -class SetDifferenceOperator implements ResolvesToArray, OperatorInterface +final class SetDifferenceOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/SetEqualsOperator.php b/src/Builder/Expression/SetEqualsOperator.php index 226a818c9..5099f33e4 100644 --- a/src/Builder/Expression/SetEqualsOperator.php +++ b/src/Builder/Expression/SetEqualsOperator.php @@ -20,8 +20,9 @@ * Returns true if the input sets have the same distinct elements. Accepts two or more argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/ + * @internal */ -class SetEqualsOperator implements ResolvesToBool, OperatorInterface +final class SetEqualsOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SetFieldOperator.php b/src/Builder/Expression/SetFieldOperator.php index aa527ea2a..921c2f51c 100644 --- a/src/Builder/Expression/SetFieldOperator.php +++ b/src/Builder/Expression/SetFieldOperator.php @@ -21,8 +21,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/ + * @internal */ -class SetFieldOperator implements ResolvesToObject, OperatorInterface +final class SetFieldOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['field' => 'field', 'input' => 'input', 'value' => 'value']; diff --git a/src/Builder/Expression/SetIntersectionOperator.php b/src/Builder/Expression/SetIntersectionOperator.php index 4f193351b..a5d8116a4 100644 --- a/src/Builder/Expression/SetIntersectionOperator.php +++ b/src/Builder/Expression/SetIntersectionOperator.php @@ -20,8 +20,9 @@ * Returns a set with elements that appear in all of the input sets. Accepts any number of argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/ + * @internal */ -class SetIntersectionOperator implements ResolvesToArray, OperatorInterface +final class SetIntersectionOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SetIsSubsetOperator.php b/src/Builder/Expression/SetIsSubsetOperator.php index 77a740e91..7c2baeb40 100644 --- a/src/Builder/Expression/SetIsSubsetOperator.php +++ b/src/Builder/Expression/SetIsSubsetOperator.php @@ -21,8 +21,9 @@ * Returns true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subset. Accepts exactly two argument expressions. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/ + * @internal */ -class SetIsSubsetOperator implements ResolvesToBool, OperatorInterface +final class SetIsSubsetOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/SetUnionOperator.php b/src/Builder/Expression/SetUnionOperator.php index 2966d324d..132e2701b 100644 --- a/src/Builder/Expression/SetUnionOperator.php +++ b/src/Builder/Expression/SetUnionOperator.php @@ -20,8 +20,9 @@ * Returns a set with elements that appear in any of the input sets. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/ + * @internal */ -class SetUnionOperator implements ResolvesToArray, OperatorInterface +final class SetUnionOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SinOperator.php b/src/Builder/Expression/SinOperator.php index e7bea1704..76f72f4f0 100644 --- a/src/Builder/Expression/SinOperator.php +++ b/src/Builder/Expression/SinOperator.php @@ -17,8 +17,9 @@ * Returns the sine of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/ + * @internal */ -class SinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class SinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SinhOperator.php b/src/Builder/Expression/SinhOperator.php index f650f3981..d5dfa929c 100644 --- a/src/Builder/Expression/SinhOperator.php +++ b/src/Builder/Expression/SinhOperator.php @@ -17,8 +17,9 @@ * Returns the hyperbolic sine of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/ + * @internal */ -class SinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class SinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SizeOperator.php b/src/Builder/Expression/SizeOperator.php index aeb312f11..964f420ac 100644 --- a/src/Builder/Expression/SizeOperator.php +++ b/src/Builder/Expression/SizeOperator.php @@ -21,8 +21,9 @@ * Returns the number of elements in the array. Accepts a single expression as argument. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/ + * @internal */ -class SizeOperator implements ResolvesToInt, OperatorInterface +final class SizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SliceOperator.php b/src/Builder/Expression/SliceOperator.php index fc435a51a..96599fcb1 100644 --- a/src/Builder/Expression/SliceOperator.php +++ b/src/Builder/Expression/SliceOperator.php @@ -22,8 +22,9 @@ * Returns a subset of an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/ + * @internal */ -class SliceOperator implements ResolvesToArray, OperatorInterface +final class SliceOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression' => 'expression', 'n' => 'n', 'position' => 'position']; diff --git a/src/Builder/Expression/SortArrayOperator.php b/src/Builder/Expression/SortArrayOperator.php index 8ad43924c..f85d07cc4 100644 --- a/src/Builder/Expression/SortArrayOperator.php +++ b/src/Builder/Expression/SortArrayOperator.php @@ -25,8 +25,9 @@ * Sorts the elements of an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/ + * @internal */ -class SortArrayOperator implements ResolvesToArray, OperatorInterface +final class SortArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'sortBy' => 'sortBy']; diff --git a/src/Builder/Expression/SplitOperator.php b/src/Builder/Expression/SplitOperator.php index 60ddf4926..e1e0b0cca 100644 --- a/src/Builder/Expression/SplitOperator.php +++ b/src/Builder/Expression/SplitOperator.php @@ -15,8 +15,9 @@ * Splits a string into substrings based on a delimiter. Returns an array of substrings. If the delimiter is not found within the string, returns an array containing the original string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/ + * @internal */ -class SplitOperator implements ResolvesToArray, OperatorInterface +final class SplitOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['string' => 'string', 'delimiter' => 'delimiter']; diff --git a/src/Builder/Expression/SqrtOperator.php b/src/Builder/Expression/SqrtOperator.php index 7ac1e20cc..62f73fe0b 100644 --- a/src/Builder/Expression/SqrtOperator.php +++ b/src/Builder/Expression/SqrtOperator.php @@ -17,8 +17,9 @@ * Calculates the square root. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/ + * @internal */ -class SqrtOperator implements ResolvesToDouble, OperatorInterface +final class SqrtOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['number' => 'number']; diff --git a/src/Builder/Expression/StdDevPopOperator.php b/src/Builder/Expression/StdDevPopOperator.php index 181db1946..ab6bccecf 100644 --- a/src/Builder/Expression/StdDevPopOperator.php +++ b/src/Builder/Expression/StdDevPopOperator.php @@ -22,8 +22,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/ + * @internal */ -class StdDevPopOperator implements ResolvesToDouble, OperatorInterface +final class StdDevPopOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/StdDevSampOperator.php b/src/Builder/Expression/StdDevSampOperator.php index 34cb9cf04..0c4e31a68 100644 --- a/src/Builder/Expression/StdDevSampOperator.php +++ b/src/Builder/Expression/StdDevSampOperator.php @@ -21,8 +21,9 @@ * If the values represent the entire population of data or you do not wish to generalize about a larger population, use $stdDevPop instead. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/ + * @internal */ -class StdDevSampOperator implements ResolvesToDouble, OperatorInterface +final class StdDevSampOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/StrLenBytesOperator.php b/src/Builder/Expression/StrLenBytesOperator.php index 33d9794c2..26e899e99 100644 --- a/src/Builder/Expression/StrLenBytesOperator.php +++ b/src/Builder/Expression/StrLenBytesOperator.php @@ -15,8 +15,9 @@ * Returns the number of UTF-8 encoded bytes in a string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/ + * @internal */ -class StrLenBytesOperator implements ResolvesToInt, OperatorInterface +final class StrLenBytesOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/StrLenCPOperator.php b/src/Builder/Expression/StrLenCPOperator.php index 31334c5ed..b6d97c37a 100644 --- a/src/Builder/Expression/StrLenCPOperator.php +++ b/src/Builder/Expression/StrLenCPOperator.php @@ -15,8 +15,9 @@ * Returns the number of UTF-8 code points in a string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/ + * @internal */ -class StrLenCPOperator implements ResolvesToInt, OperatorInterface +final class StrLenCPOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/StrcasecmpOperator.php b/src/Builder/Expression/StrcasecmpOperator.php index 95a3b3118..2090cdda1 100644 --- a/src/Builder/Expression/StrcasecmpOperator.php +++ b/src/Builder/Expression/StrcasecmpOperator.php @@ -15,8 +15,9 @@ * Performs case-insensitive string comparison and returns: 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/ + * @internal */ -class StrcasecmpOperator implements ResolvesToInt, OperatorInterface +final class StrcasecmpOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/SubstrBytesOperator.php b/src/Builder/Expression/SubstrBytesOperator.php index 48c1d1dfe..9d20afe67 100644 --- a/src/Builder/Expression/SubstrBytesOperator.php +++ b/src/Builder/Expression/SubstrBytesOperator.php @@ -15,8 +15,9 @@ * Returns the substring of a string. Starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the specified number of bytes. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/ + * @internal */ -class SubstrBytesOperator implements ResolvesToString, OperatorInterface +final class SubstrBytesOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; diff --git a/src/Builder/Expression/SubstrCPOperator.php b/src/Builder/Expression/SubstrCPOperator.php index b1e810719..93af8d80c 100644 --- a/src/Builder/Expression/SubstrCPOperator.php +++ b/src/Builder/Expression/SubstrCPOperator.php @@ -15,8 +15,9 @@ * Returns the substring of a string. Starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string and continues for the number of code points specified. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/ + * @internal */ -class SubstrCPOperator implements ResolvesToString, OperatorInterface +final class SubstrCPOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; diff --git a/src/Builder/Expression/SubstrOperator.php b/src/Builder/Expression/SubstrOperator.php index 0b9b7cfae..6f34320dc 100644 --- a/src/Builder/Expression/SubstrOperator.php +++ b/src/Builder/Expression/SubstrOperator.php @@ -15,8 +15,9 @@ * Deprecated. Use $substrBytes or $substrCP. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/ + * @internal */ -class SubstrOperator implements ResolvesToString, OperatorInterface +final class SubstrOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; diff --git a/src/Builder/Expression/SubtractOperator.php b/src/Builder/Expression/SubtractOperator.php index a734f5a49..35b1075d4 100644 --- a/src/Builder/Expression/SubtractOperator.php +++ b/src/Builder/Expression/SubtractOperator.php @@ -18,8 +18,9 @@ * Returns the result of subtracting the second value from the first. If the two values are numbers, return the difference. If the two values are dates, return the difference in milliseconds. If the two values are a date and a number in milliseconds, return the resulting date. Accepts two argument expressions. If the two values are a date and a number, specify the date argument first as it is not meaningful to subtract a date from a number. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/ + * @internal */ -class SubtractOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface +final class SubtractOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; diff --git a/src/Builder/Expression/SumOperator.php b/src/Builder/Expression/SumOperator.php index 2104cb88e..ccf797785 100644 --- a/src/Builder/Expression/SumOperator.php +++ b/src/Builder/Expression/SumOperator.php @@ -23,8 +23,9 @@ * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ + * @internal */ -class SumOperator implements ResolvesToNumber, OperatorInterface +final class SumOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/SwitchOperator.php b/src/Builder/Expression/SwitchOperator.php index 3619919b1..e8450ebdb 100644 --- a/src/Builder/Expression/SwitchOperator.php +++ b/src/Builder/Expression/SwitchOperator.php @@ -25,8 +25,9 @@ * Evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/ + * @internal */ -class SwitchOperator implements ResolvesToAny, OperatorInterface +final class SwitchOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['branches' => 'branches', 'default' => 'default']; diff --git a/src/Builder/Expression/TanOperator.php b/src/Builder/Expression/TanOperator.php index e1cc86b9a..f0f8c9bce 100644 --- a/src/Builder/Expression/TanOperator.php +++ b/src/Builder/Expression/TanOperator.php @@ -17,8 +17,9 @@ * Returns the tangent of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/ + * @internal */ -class TanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class TanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/TanhOperator.php b/src/Builder/Expression/TanhOperator.php index 111f26ad3..e94baa97f 100644 --- a/src/Builder/Expression/TanhOperator.php +++ b/src/Builder/Expression/TanhOperator.php @@ -17,8 +17,9 @@ * Returns the hyperbolic tangent of a value that is measured in radians. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/ + * @internal */ -class TanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface +final class TanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToBoolOperator.php b/src/Builder/Expression/ToBoolOperator.php index 90edfe8e7..364a6f805 100644 --- a/src/Builder/Expression/ToBoolOperator.php +++ b/src/Builder/Expression/ToBoolOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/ + * @internal */ -class ToBoolOperator implements ResolvesToBool, OperatorInterface +final class ToBoolOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToDateOperator.php b/src/Builder/Expression/ToDateOperator.php index 5b91d684f..d94782a55 100644 --- a/src/Builder/Expression/ToDateOperator.php +++ b/src/Builder/Expression/ToDateOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/ + * @internal */ -class ToDateOperator implements ResolvesToDate, OperatorInterface +final class ToDateOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToDecimalOperator.php b/src/Builder/Expression/ToDecimalOperator.php index a36b62426..f4e5ee3cd 100644 --- a/src/Builder/Expression/ToDecimalOperator.php +++ b/src/Builder/Expression/ToDecimalOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/ + * @internal */ -class ToDecimalOperator implements ResolvesToDecimal, OperatorInterface +final class ToDecimalOperator implements ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToDoubleOperator.php b/src/Builder/Expression/ToDoubleOperator.php index ea1e4dba2..c411a52d5 100644 --- a/src/Builder/Expression/ToDoubleOperator.php +++ b/src/Builder/Expression/ToDoubleOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/ + * @internal */ -class ToDoubleOperator implements ResolvesToDouble, OperatorInterface +final class ToDoubleOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToHashedIndexKeyOperator.php b/src/Builder/Expression/ToHashedIndexKeyOperator.php index ab8bd633f..ad41fc8b1 100644 --- a/src/Builder/Expression/ToHashedIndexKeyOperator.php +++ b/src/Builder/Expression/ToHashedIndexKeyOperator.php @@ -18,8 +18,9 @@ * Computes and returns the hash value of the input expression using the same hash function that MongoDB uses to create a hashed index. A hash function maps a key or string to a fixed-size numeric value. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/ + * @internal */ -class ToHashedIndexKeyOperator implements ResolvesToLong, OperatorInterface +final class ToHashedIndexKeyOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Expression/ToIntOperator.php b/src/Builder/Expression/ToIntOperator.php index 4a6aaa4d5..1d7f6538a 100644 --- a/src/Builder/Expression/ToIntOperator.php +++ b/src/Builder/Expression/ToIntOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/ + * @internal */ -class ToIntOperator implements ResolvesToInt, OperatorInterface +final class ToIntOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToLongOperator.php b/src/Builder/Expression/ToLongOperator.php index 73e5d34ec..54acf0052 100644 --- a/src/Builder/Expression/ToLongOperator.php +++ b/src/Builder/Expression/ToLongOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/ + * @internal */ -class ToLongOperator implements ResolvesToLong, OperatorInterface +final class ToLongOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToLowerOperator.php b/src/Builder/Expression/ToLowerOperator.php index 7496af863..83ff37e66 100644 --- a/src/Builder/Expression/ToLowerOperator.php +++ b/src/Builder/Expression/ToLowerOperator.php @@ -15,8 +15,9 @@ * Converts a string to lowercase. Accepts a single argument expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/ + * @internal */ -class ToLowerOperator implements ResolvesToString, OperatorInterface +final class ToLowerOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToObjectIdOperator.php b/src/Builder/Expression/ToObjectIdOperator.php index 2e9e8346e..f820a3d55 100644 --- a/src/Builder/Expression/ToObjectIdOperator.php +++ b/src/Builder/Expression/ToObjectIdOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/ + * @internal */ -class ToObjectIdOperator implements ResolvesToObjectId, OperatorInterface +final class ToObjectIdOperator implements ResolvesToObjectId, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToStringOperator.php b/src/Builder/Expression/ToStringOperator.php index c90cf2d62..8c0a47bbf 100644 --- a/src/Builder/Expression/ToStringOperator.php +++ b/src/Builder/Expression/ToStringOperator.php @@ -19,8 +19,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/ + * @internal */ -class ToStringOperator implements ResolvesToString, OperatorInterface +final class ToStringOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/ToUpperOperator.php b/src/Builder/Expression/ToUpperOperator.php index 757afcf23..93e896b09 100644 --- a/src/Builder/Expression/ToUpperOperator.php +++ b/src/Builder/Expression/ToUpperOperator.php @@ -15,8 +15,9 @@ * Converts a string to uppercase. Accepts a single argument expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/ + * @internal */ -class ToUpperOperator implements ResolvesToString, OperatorInterface +final class ToUpperOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/TrimOperator.php b/src/Builder/Expression/TrimOperator.php index ffcc89609..c524bdfe0 100644 --- a/src/Builder/Expression/TrimOperator.php +++ b/src/Builder/Expression/TrimOperator.php @@ -17,8 +17,9 @@ * New in MongoDB 4.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/ + * @internal */ -class TrimOperator implements ResolvesToString, OperatorInterface +final class TrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['input' => 'input', 'chars' => 'chars']; diff --git a/src/Builder/Expression/TruncOperator.php b/src/Builder/Expression/TruncOperator.php index fcfa43721..df988e622 100644 --- a/src/Builder/Expression/TruncOperator.php +++ b/src/Builder/Expression/TruncOperator.php @@ -18,8 +18,9 @@ * Truncates a number to a whole integer or to a specified decimal place. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/ + * @internal */ -class TruncOperator implements ResolvesToString, OperatorInterface +final class TruncOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['number' => 'number', 'place' => 'place']; diff --git a/src/Builder/Expression/TsIncrementOperator.php b/src/Builder/Expression/TsIncrementOperator.php index 56aa7bb53..677a30375 100644 --- a/src/Builder/Expression/TsIncrementOperator.php +++ b/src/Builder/Expression/TsIncrementOperator.php @@ -17,8 +17,9 @@ * New in MongoDB 5.1. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/ + * @internal */ -class TsIncrementOperator implements ResolvesToLong, OperatorInterface +final class TsIncrementOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/TsSecondOperator.php b/src/Builder/Expression/TsSecondOperator.php index 7a00cf7fd..3c3a995d8 100644 --- a/src/Builder/Expression/TsSecondOperator.php +++ b/src/Builder/Expression/TsSecondOperator.php @@ -17,8 +17,9 @@ * New in MongoDB 5.1. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/ + * @internal */ -class TsSecondOperator implements ResolvesToLong, OperatorInterface +final class TsSecondOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/TypeOperator.php b/src/Builder/Expression/TypeOperator.php index e43d8d03d..516b1a0af 100644 --- a/src/Builder/Expression/TypeOperator.php +++ b/src/Builder/Expression/TypeOperator.php @@ -18,8 +18,9 @@ * Return the BSON data type of the field. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/ + * @internal */ -class TypeOperator implements ResolvesToString, OperatorInterface +final class TypeOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Expression/UnsetFieldOperator.php b/src/Builder/Expression/UnsetFieldOperator.php index 056768ea3..da5fdf4ac 100644 --- a/src/Builder/Expression/UnsetFieldOperator.php +++ b/src/Builder/Expression/UnsetFieldOperator.php @@ -19,8 +19,9 @@ * $unsetField is an alias for $setField using $$REMOVE to remove fields. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/ + * @internal */ -class UnsetFieldOperator implements ResolvesToObject, OperatorInterface +final class UnsetFieldOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['field' => 'field', 'input' => 'input']; diff --git a/src/Builder/Expression/WeekOperator.php b/src/Builder/Expression/WeekOperator.php index 701864106..006e3371d 100644 --- a/src/Builder/Expression/WeekOperator.php +++ b/src/Builder/Expression/WeekOperator.php @@ -19,8 +19,9 @@ * Returns the week number for a date as a number between 0 (the partial week that precedes the first Sunday of the year) and 53 (leap year). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/ + * @internal */ -class WeekOperator implements ResolvesToInt, OperatorInterface +final class WeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/YearOperator.php b/src/Builder/Expression/YearOperator.php index 1ecf3f706..4b7d98f7f 100644 --- a/src/Builder/Expression/YearOperator.php +++ b/src/Builder/Expression/YearOperator.php @@ -19,8 +19,9 @@ * Returns the year for a date as a number (e.g. 2014). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/ + * @internal */ -class YearOperator implements ResolvesToInt, OperatorInterface +final class YearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['date' => 'date', 'timezone' => 'timezone']; diff --git a/src/Builder/Expression/ZipOperator.php b/src/Builder/Expression/ZipOperator.php index 962248a26..591c0c125 100644 --- a/src/Builder/Expression/ZipOperator.php +++ b/src/Builder/Expression/ZipOperator.php @@ -22,8 +22,9 @@ * Merge two arrays together. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/ + * @internal */ -class ZipOperator implements ResolvesToArray, OperatorInterface +final class ZipOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['inputs' => 'inputs', 'useLongestLength' => 'useLongestLength', 'defaults' => 'defaults']; diff --git a/src/Builder/Query/AllOperator.php b/src/Builder/Query/AllOperator.php index 735c4ed04..558cfea3b 100644 --- a/src/Builder/Query/AllOperator.php +++ b/src/Builder/Query/AllOperator.php @@ -21,8 +21,9 @@ * Matches arrays that contain all elements specified in the query. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/all/ + * @internal */ -class AllOperator implements FieldQueryInterface, OperatorInterface +final class AllOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/AndOperator.php b/src/Builder/Query/AndOperator.php index f9c3bc774..7ed9b0d6d 100644 --- a/src/Builder/Query/AndOperator.php +++ b/src/Builder/Query/AndOperator.php @@ -19,8 +19,9 @@ * Joins query clauses with a logical AND returns all documents that match the conditions of both clauses. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/and/ + * @internal */ -class AndOperator implements QueryInterface, OperatorInterface +final class AndOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['queries' => 'queries']; diff --git a/src/Builder/Query/BitsAllClearOperator.php b/src/Builder/Query/BitsAllClearOperator.php index 6590be2bc..ad781b6bd 100644 --- a/src/Builder/Query/BitsAllClearOperator.php +++ b/src/Builder/Query/BitsAllClearOperator.php @@ -23,8 +23,9 @@ * Matches numeric or binary values in which a set of bit positions all have a value of 0. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllClear/ + * @internal */ -class BitsAllClearOperator implements FieldQueryInterface, OperatorInterface +final class BitsAllClearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['bitmask' => 'bitmask']; diff --git a/src/Builder/Query/BitsAllSetOperator.php b/src/Builder/Query/BitsAllSetOperator.php index cc6cf317f..f28d7aaaa 100644 --- a/src/Builder/Query/BitsAllSetOperator.php +++ b/src/Builder/Query/BitsAllSetOperator.php @@ -23,8 +23,9 @@ * Matches numeric or binary values in which a set of bit positions all have a value of 1. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/ + * @internal */ -class BitsAllSetOperator implements FieldQueryInterface, OperatorInterface +final class BitsAllSetOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['bitmask' => 'bitmask']; diff --git a/src/Builder/Query/BitsAnyClearOperator.php b/src/Builder/Query/BitsAnyClearOperator.php index 47cf5cd6e..cf6a4baa1 100644 --- a/src/Builder/Query/BitsAnyClearOperator.php +++ b/src/Builder/Query/BitsAnyClearOperator.php @@ -23,8 +23,9 @@ * Matches numeric or binary values in which any bit from a set of bit positions has a value of 0. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnyClear/ + * @internal */ -class BitsAnyClearOperator implements FieldQueryInterface, OperatorInterface +final class BitsAnyClearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['bitmask' => 'bitmask']; diff --git a/src/Builder/Query/BitsAnySetOperator.php b/src/Builder/Query/BitsAnySetOperator.php index 3f5b73550..64a3e3e48 100644 --- a/src/Builder/Query/BitsAnySetOperator.php +++ b/src/Builder/Query/BitsAnySetOperator.php @@ -23,8 +23,9 @@ * Matches numeric or binary values in which any bit from a set of bit positions has a value of 1. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/bitsAnySet/ + * @internal */ -class BitsAnySetOperator implements FieldQueryInterface, OperatorInterface +final class BitsAnySetOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['bitmask' => 'bitmask']; diff --git a/src/Builder/Query/BoxOperator.php b/src/Builder/Query/BoxOperator.php index fedcf4b8f..8e07cfe5a 100644 --- a/src/Builder/Query/BoxOperator.php +++ b/src/Builder/Query/BoxOperator.php @@ -22,8 +22,9 @@ * Specifies a rectangular box using legacy coordinate pairs for $geoWithin queries. The 2d index supports $box. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/box/ + * @internal */ -class BoxOperator implements GeometryInterface, OperatorInterface +final class BoxOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/CenterOperator.php b/src/Builder/Query/CenterOperator.php index c19a19812..e9c4b057a 100644 --- a/src/Builder/Query/CenterOperator.php +++ b/src/Builder/Query/CenterOperator.php @@ -22,8 +22,9 @@ * Specifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry. The 2d index supports $center. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/center/ + * @internal */ -class CenterOperator implements GeometryInterface, OperatorInterface +final class CenterOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/CenterSphereOperator.php b/src/Builder/Query/CenterSphereOperator.php index 56dd2ab33..373cf2190 100644 --- a/src/Builder/Query/CenterSphereOperator.php +++ b/src/Builder/Query/CenterSphereOperator.php @@ -22,8 +22,9 @@ * Specifies a circle using either legacy coordinate pairs or GeoJSON format for $geoWithin queries when using spherical geometry. The 2dsphere and 2d indexes support $centerSphere. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/centerSphere/ + * @internal */ -class CenterSphereOperator implements GeometryInterface, OperatorInterface +final class CenterSphereOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/CommentOperator.php b/src/Builder/Query/CommentOperator.php index 6292ec307..58ba0c126 100644 --- a/src/Builder/Query/CommentOperator.php +++ b/src/Builder/Query/CommentOperator.php @@ -16,8 +16,9 @@ * Adds a comment to a query predicate. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/comment/ + * @internal */ -class CommentOperator implements QueryInterface, OperatorInterface +final class CommentOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['comment' => 'comment']; diff --git a/src/Builder/Query/ElemMatchOperator.php b/src/Builder/Query/ElemMatchOperator.php index 7a1edcf3f..e56b1e43c 100644 --- a/src/Builder/Query/ElemMatchOperator.php +++ b/src/Builder/Query/ElemMatchOperator.php @@ -22,8 +22,9 @@ * The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/ + * @internal */ -class ElemMatchOperator implements FieldQueryInterface, OperatorInterface +final class ElemMatchOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['query' => 'query']; diff --git a/src/Builder/Query/EqOperator.php b/src/Builder/Query/EqOperator.php index 6bacfe6a7..ba7b530a3 100644 --- a/src/Builder/Query/EqOperator.php +++ b/src/Builder/Query/EqOperator.php @@ -18,8 +18,9 @@ * Matches values that are equal to a specified value. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/eq/ + * @internal */ -class EqOperator implements FieldQueryInterface, OperatorInterface +final class EqOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/ExistsOperator.php b/src/Builder/Query/ExistsOperator.php index 80f078124..21178931c 100644 --- a/src/Builder/Query/ExistsOperator.php +++ b/src/Builder/Query/ExistsOperator.php @@ -16,8 +16,9 @@ * Matches documents that have the specified field. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/exists/ + * @internal */ -class ExistsOperator implements FieldQueryInterface, OperatorInterface +final class ExistsOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['exists' => 'exists']; diff --git a/src/Builder/Query/ExprOperator.php b/src/Builder/Query/ExprOperator.php index 5ab3aa482..bea9c861d 100644 --- a/src/Builder/Query/ExprOperator.php +++ b/src/Builder/Query/ExprOperator.php @@ -19,8 +19,9 @@ * Allows use of aggregation expressions within the query language. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/expr/ + * @internal */ -class ExprOperator implements QueryInterface, OperatorInterface +final class ExprOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Query/GeoIntersectsOperator.php b/src/Builder/Query/GeoIntersectsOperator.php index 0c9bd760c..c5e4b67c9 100644 --- a/src/Builder/Query/GeoIntersectsOperator.php +++ b/src/Builder/Query/GeoIntersectsOperator.php @@ -20,8 +20,9 @@ * Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/geoIntersects/ + * @internal */ -class GeoIntersectsOperator implements FieldQueryInterface, OperatorInterface +final class GeoIntersectsOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['geometry' => null]; diff --git a/src/Builder/Query/GeoWithinOperator.php b/src/Builder/Query/GeoWithinOperator.php index 0dfb751dd..4e0dae8b2 100644 --- a/src/Builder/Query/GeoWithinOperator.php +++ b/src/Builder/Query/GeoWithinOperator.php @@ -20,8 +20,9 @@ * Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/ + * @internal */ -class GeoWithinOperator implements FieldQueryInterface, OperatorInterface +final class GeoWithinOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['geometry' => null]; diff --git a/src/Builder/Query/GeometryOperator.php b/src/Builder/Query/GeometryOperator.php index 936b8a1a8..7430fe0ef 100644 --- a/src/Builder/Query/GeometryOperator.php +++ b/src/Builder/Query/GeometryOperator.php @@ -26,8 +26,9 @@ * Specifies a geometry in GeoJSON format to geospatial query operators. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/geometry/ + * @internal */ -class GeometryOperator implements GeometryInterface, OperatorInterface +final class GeometryOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['type' => 'type', 'coordinates' => 'coordinates', 'crs' => 'crs']; diff --git a/src/Builder/Query/GtOperator.php b/src/Builder/Query/GtOperator.php index e651d72e6..8e1c783ed 100644 --- a/src/Builder/Query/GtOperator.php +++ b/src/Builder/Query/GtOperator.php @@ -18,8 +18,9 @@ * Matches values that are greater than a specified value. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/gt/ + * @internal */ -class GtOperator implements FieldQueryInterface, OperatorInterface +final class GtOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/GteOperator.php b/src/Builder/Query/GteOperator.php index 1b4dbd054..59c992127 100644 --- a/src/Builder/Query/GteOperator.php +++ b/src/Builder/Query/GteOperator.php @@ -18,8 +18,9 @@ * Matches values that are greater than or equal to a specified value. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/gte/ + * @internal */ -class GteOperator implements FieldQueryInterface, OperatorInterface +final class GteOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/InOperator.php b/src/Builder/Query/InOperator.php index 4568667d0..60d90b4db 100644 --- a/src/Builder/Query/InOperator.php +++ b/src/Builder/Query/InOperator.php @@ -22,8 +22,9 @@ * Matches any of the values specified in an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/in/ + * @internal */ -class InOperator implements FieldQueryInterface, OperatorInterface +final class InOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/JsonSchemaOperator.php b/src/Builder/Query/JsonSchemaOperator.php index 869247f2e..aea2de45d 100644 --- a/src/Builder/Query/JsonSchemaOperator.php +++ b/src/Builder/Query/JsonSchemaOperator.php @@ -19,8 +19,9 @@ * Validate documents against the given JSON Schema. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/jsonSchema/ + * @internal */ -class JsonSchemaOperator implements QueryInterface, OperatorInterface +final class JsonSchemaOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['schema' => 'schema']; diff --git a/src/Builder/Query/LtOperator.php b/src/Builder/Query/LtOperator.php index dcfebce40..f34bc688b 100644 --- a/src/Builder/Query/LtOperator.php +++ b/src/Builder/Query/LtOperator.php @@ -18,8 +18,9 @@ * Matches values that are less than a specified value. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/lt/ + * @internal */ -class LtOperator implements FieldQueryInterface, OperatorInterface +final class LtOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/LteOperator.php b/src/Builder/Query/LteOperator.php index cb260c8d7..f671bd228 100644 --- a/src/Builder/Query/LteOperator.php +++ b/src/Builder/Query/LteOperator.php @@ -18,8 +18,9 @@ * Matches values that are less than or equal to a specified value. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/lte/ + * @internal */ -class LteOperator implements FieldQueryInterface, OperatorInterface +final class LteOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/MaxDistanceOperator.php b/src/Builder/Query/MaxDistanceOperator.php index 92b3129da..5372f7bbf 100644 --- a/src/Builder/Query/MaxDistanceOperator.php +++ b/src/Builder/Query/MaxDistanceOperator.php @@ -18,8 +18,9 @@ * Specifies a maximum distance to limit the results of $near and $nearSphere queries. The 2dsphere and 2d indexes support $maxDistance. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/maxDistance/ + * @internal */ -class MaxDistanceOperator implements FieldQueryInterface, OperatorInterface +final class MaxDistanceOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/MinDistanceOperator.php b/src/Builder/Query/MinDistanceOperator.php index cdd97fe32..bd963a84d 100644 --- a/src/Builder/Query/MinDistanceOperator.php +++ b/src/Builder/Query/MinDistanceOperator.php @@ -17,8 +17,9 @@ * Specifies a minimum distance to limit the results of $near and $nearSphere queries. For use with 2dsphere index only. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/minDistance/ + * @internal */ -class MinDistanceOperator implements FieldQueryInterface, OperatorInterface +final class MinDistanceOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/ModOperator.php b/src/Builder/Query/ModOperator.php index 749785387..a6890965a 100644 --- a/src/Builder/Query/ModOperator.php +++ b/src/Builder/Query/ModOperator.php @@ -18,8 +18,9 @@ * Performs a modulo operation on the value of a field and selects documents with a specified result. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/mod/ + * @internal */ -class ModOperator implements FieldQueryInterface, OperatorInterface +final class ModOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Array; public const PROPERTIES = ['divisor' => 'divisor', 'remainder' => 'remainder']; diff --git a/src/Builder/Query/NeOperator.php b/src/Builder/Query/NeOperator.php index de2f35bb5..72861b76f 100644 --- a/src/Builder/Query/NeOperator.php +++ b/src/Builder/Query/NeOperator.php @@ -18,8 +18,9 @@ * Matches all values that are not equal to a specified value. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/ne/ + * @internal */ -class NeOperator implements FieldQueryInterface, OperatorInterface +final class NeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/NearOperator.php b/src/Builder/Query/NearOperator.php index ec59bbfdf..4807716fe 100644 --- a/src/Builder/Query/NearOperator.php +++ b/src/Builder/Query/NearOperator.php @@ -23,8 +23,9 @@ * Returns geospatial objects in proximity to a point. Requires a geospatial index. The 2dsphere and 2d indexes support $near. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/near/ + * @internal */ -class NearOperator implements FieldQueryInterface, OperatorInterface +final class NearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['geometry' => null, 'maxDistance' => '$maxDistance', 'minDistance' => '$minDistance']; diff --git a/src/Builder/Query/NearSphereOperator.php b/src/Builder/Query/NearSphereOperator.php index 502f18db8..71af4c489 100644 --- a/src/Builder/Query/NearSphereOperator.php +++ b/src/Builder/Query/NearSphereOperator.php @@ -23,8 +23,9 @@ * Returns geospatial objects in proximity to a point on a sphere. Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/nearSphere/ + * @internal */ -class NearSphereOperator implements FieldQueryInterface, OperatorInterface +final class NearSphereOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['geometry' => null, 'maxDistance' => '$maxDistance', 'minDistance' => '$minDistance']; diff --git a/src/Builder/Query/NinOperator.php b/src/Builder/Query/NinOperator.php index 64550e59d..f1a50bd39 100644 --- a/src/Builder/Query/NinOperator.php +++ b/src/Builder/Query/NinOperator.php @@ -22,8 +22,9 @@ * Matches none of the values specified in an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/nin/ + * @internal */ -class NinOperator implements FieldQueryInterface, OperatorInterface +final class NinOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/NorOperator.php b/src/Builder/Query/NorOperator.php index 71c134170..4fdf9e3e1 100644 --- a/src/Builder/Query/NorOperator.php +++ b/src/Builder/Query/NorOperator.php @@ -19,8 +19,9 @@ * Joins query clauses with a logical NOR returns all documents that fail to match both clauses. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/nor/ + * @internal */ -class NorOperator implements QueryInterface, OperatorInterface +final class NorOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['queries' => 'queries']; diff --git a/src/Builder/Query/NotOperator.php b/src/Builder/Query/NotOperator.php index b4ee6f9c6..ee3c12d34 100644 --- a/src/Builder/Query/NotOperator.php +++ b/src/Builder/Query/NotOperator.php @@ -18,8 +18,9 @@ * Inverts the effect of a query expression and returns documents that do not match the query expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/not/ + * @internal */ -class NotOperator implements FieldQueryInterface, OperatorInterface +final class NotOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Query/OrOperator.php b/src/Builder/Query/OrOperator.php index eeb7a4fe3..a9d246a9f 100644 --- a/src/Builder/Query/OrOperator.php +++ b/src/Builder/Query/OrOperator.php @@ -19,8 +19,9 @@ * Joins query clauses with a logical OR returns all documents that match the conditions of either clause. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/or/ + * @internal */ -class OrOperator implements QueryInterface, OperatorInterface +final class OrOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['queries' => 'queries']; diff --git a/src/Builder/Query/PolygonOperator.php b/src/Builder/Query/PolygonOperator.php index 7337e2be5..a512a5259 100644 --- a/src/Builder/Query/PolygonOperator.php +++ b/src/Builder/Query/PolygonOperator.php @@ -22,8 +22,9 @@ * Specifies a polygon to using legacy coordinate pairs for $geoWithin queries. The 2d index supports $center. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/polygon/ + * @internal */ -class PolygonOperator implements GeometryInterface, OperatorInterface +final class PolygonOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['points' => 'points']; diff --git a/src/Builder/Query/RandOperator.php b/src/Builder/Query/RandOperator.php index 251f50ea1..7cea63382 100644 --- a/src/Builder/Query/RandOperator.php +++ b/src/Builder/Query/RandOperator.php @@ -16,8 +16,9 @@ * Generates a random float between 0 and 1. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/rand/ + * @internal */ -class RandOperator implements ResolvesToDouble, OperatorInterface +final class RandOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Query/RegexOperator.php b/src/Builder/Query/RegexOperator.php index 661858925..e0addbbb0 100644 --- a/src/Builder/Query/RegexOperator.php +++ b/src/Builder/Query/RegexOperator.php @@ -17,8 +17,9 @@ * Selects documents where values match a specified regular expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/regex/ + * @internal */ -class RegexOperator implements FieldQueryInterface, OperatorInterface +final class RegexOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['regex' => 'regex']; diff --git a/src/Builder/Query/SampleRateOperator.php b/src/Builder/Query/SampleRateOperator.php index cd98624e8..df559bb9b 100644 --- a/src/Builder/Query/SampleRateOperator.php +++ b/src/Builder/Query/SampleRateOperator.php @@ -18,8 +18,9 @@ * Randomly select documents at a given rate. Although the exact number of documents selected varies on each run, the quantity chosen approximates the sample rate expressed as a percentage of the total number of documents. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/ + * @internal */ -class SampleRateOperator implements QueryInterface, OperatorInterface +final class SampleRateOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['rate' => 'rate']; diff --git a/src/Builder/Query/SizeOperator.php b/src/Builder/Query/SizeOperator.php index dae052ca1..00da6f3e2 100644 --- a/src/Builder/Query/SizeOperator.php +++ b/src/Builder/Query/SizeOperator.php @@ -16,8 +16,9 @@ * Selects documents if the array field is a specified size. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/size/ + * @internal */ -class SizeOperator implements FieldQueryInterface, OperatorInterface +final class SizeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['value' => 'value']; diff --git a/src/Builder/Query/TextOperator.php b/src/Builder/Query/TextOperator.php index 343af3248..f3028507f 100644 --- a/src/Builder/Query/TextOperator.php +++ b/src/Builder/Query/TextOperator.php @@ -17,8 +17,9 @@ * Performs text search. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/text/ + * @internal */ -class TextOperator implements QueryInterface, OperatorInterface +final class TextOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Query/TypeOperator.php b/src/Builder/Query/TypeOperator.php index f06442c7b..cdfb8ae38 100644 --- a/src/Builder/Query/TypeOperator.php +++ b/src/Builder/Query/TypeOperator.php @@ -19,8 +19,9 @@ * Selects documents if a field is of the specified type. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/type/ + * @internal */ -class TypeOperator implements FieldQueryInterface, OperatorInterface +final class TypeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['type' => 'type']; diff --git a/src/Builder/Query/WhereOperator.php b/src/Builder/Query/WhereOperator.php index 87e7caf50..90e3590ad 100644 --- a/src/Builder/Query/WhereOperator.php +++ b/src/Builder/Query/WhereOperator.php @@ -19,8 +19,9 @@ * Matches documents that satisfy a JavaScript expression. * * @see https://www.mongodb.com/docs/manual/reference/operator/query/where/ + * @internal */ -class WhereOperator implements QueryInterface, OperatorInterface +final class WhereOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['function' => 'function']; diff --git a/src/Builder/Stage/AddFieldsStage.php b/src/Builder/Stage/AddFieldsStage.php index 12edbc754..0ab28e268 100644 --- a/src/Builder/Stage/AddFieldsStage.php +++ b/src/Builder/Stage/AddFieldsStage.php @@ -22,8 +22,9 @@ * Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/ + * @internal */ -class AddFieldsStage implements StageInterface, OperatorInterface +final class AddFieldsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Stage/BucketAutoStage.php b/src/Builder/Stage/BucketAutoStage.php index 6c08506c9..028ad9f29 100644 --- a/src/Builder/Stage/BucketAutoStage.php +++ b/src/Builder/Stage/BucketAutoStage.php @@ -22,8 +22,9 @@ * Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/ + * @internal */ -class BucketAutoStage implements StageInterface, OperatorInterface +final class BucketAutoStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/BucketStage.php b/src/Builder/Stage/BucketStage.php index 2fcd15693..d3423460f 100644 --- a/src/Builder/Stage/BucketStage.php +++ b/src/Builder/Stage/BucketStage.php @@ -28,8 +28,9 @@ * Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/ + * @internal */ -class BucketStage implements StageInterface, OperatorInterface +final class BucketStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php b/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php index eb0c8ce76..ac4d37ef6 100644 --- a/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php +++ b/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php @@ -17,8 +17,9 @@ * You can only use $changeStreamSplitLargeEvent in a $changeStream pipeline and it must be the final stage in the pipeline. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/ + * @internal */ -class ChangeStreamSplitLargeEventStage implements StageInterface, OperatorInterface +final class ChangeStreamSplitLargeEventStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/ChangeStreamStage.php b/src/Builder/Stage/ChangeStreamStage.php index d75103e31..c4925a3bb 100644 --- a/src/Builder/Stage/ChangeStreamStage.php +++ b/src/Builder/Stage/ChangeStreamStage.php @@ -21,8 +21,9 @@ * Returns a Change Stream cursor for the collection or database. This stage can only occur once in an aggregation pipeline and it must occur as the first stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/ + * @internal */ -class ChangeStreamStage implements StageInterface, OperatorInterface +final class ChangeStreamStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/CollStatsStage.php b/src/Builder/Stage/CollStatsStage.php index d32ae5883..8fd74079f 100644 --- a/src/Builder/Stage/CollStatsStage.php +++ b/src/Builder/Stage/CollStatsStage.php @@ -20,8 +20,9 @@ * Returns statistics regarding a collection or view. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/ + * @internal */ -class CollStatsStage implements StageInterface, OperatorInterface +final class CollStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/CountStage.php b/src/Builder/Stage/CountStage.php index 93dd8eeb6..316f0cceb 100644 --- a/src/Builder/Stage/CountStage.php +++ b/src/Builder/Stage/CountStage.php @@ -17,8 +17,9 @@ * Distinct from the $count aggregation accumulator. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/ + * @internal */ -class CountStage implements StageInterface, OperatorInterface +final class CountStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['field' => 'field']; diff --git a/src/Builder/Stage/CurrentOpStage.php b/src/Builder/Stage/CurrentOpStage.php index 78413d2a8..2a430ef29 100644 --- a/src/Builder/Stage/CurrentOpStage.php +++ b/src/Builder/Stage/CurrentOpStage.php @@ -17,8 +17,9 @@ * Returns information on active and/or dormant operations for the MongoDB deployment. To run, use the db.aggregate() method. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/ + * @internal */ -class CurrentOpStage implements StageInterface, OperatorInterface +final class CurrentOpStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/DensifyStage.php b/src/Builder/Stage/DensifyStage.php index 953bf8b13..9626c5fca 100644 --- a/src/Builder/Stage/DensifyStage.php +++ b/src/Builder/Stage/DensifyStage.php @@ -26,8 +26,9 @@ * Creates new documents in a sequence of documents where certain values in a field are missing. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ + * @internal */ -class DensifyStage implements StageInterface, OperatorInterface +final class DensifyStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['field' => 'field', 'range' => 'range', 'partitionByFields' => 'partitionByFields']; diff --git a/src/Builder/Stage/DocumentsStage.php b/src/Builder/Stage/DocumentsStage.php index 7a7b0a82d..6c68ae9df 100644 --- a/src/Builder/Stage/DocumentsStage.php +++ b/src/Builder/Stage/DocumentsStage.php @@ -23,8 +23,9 @@ * Returns literal documents from input values. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/ + * @internal */ -class DocumentsStage implements StageInterface, OperatorInterface +final class DocumentsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['documents' => 'documents']; diff --git a/src/Builder/Stage/FacetStage.php b/src/Builder/Stage/FacetStage.php index 1a6066f71..344401892 100644 --- a/src/Builder/Stage/FacetStage.php +++ b/src/Builder/Stage/FacetStage.php @@ -23,8 +23,9 @@ * Processes multiple aggregation pipelines within a single stage on the same set of input documents. Enables the creation of multi-faceted aggregations capable of characterizing data across multiple dimensions, or facets, in a single stage. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/ + * @internal */ -class FacetStage implements StageInterface, OperatorInterface +final class FacetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['facet' => 'facet']; diff --git a/src/Builder/Stage/FillStage.php b/src/Builder/Stage/FillStage.php index f5eac51e1..74eeae78c 100644 --- a/src/Builder/Stage/FillStage.php +++ b/src/Builder/Stage/FillStage.php @@ -26,8 +26,9 @@ * Populates null and missing field values within documents. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ + * @internal */ -class FillStage implements StageInterface, OperatorInterface +final class FillStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/GeoNearStage.php b/src/Builder/Stage/GeoNearStage.php index 3864d5f43..342eedb1d 100644 --- a/src/Builder/Stage/GeoNearStage.php +++ b/src/Builder/Stage/GeoNearStage.php @@ -27,8 +27,9 @@ * Returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match, $sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/ + * @internal */ -class GeoNearStage implements StageInterface, OperatorInterface +final class GeoNearStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/GraphLookupStage.php b/src/Builder/Stage/GraphLookupStage.php index 7809e146f..52c2d322f 100644 --- a/src/Builder/Stage/GraphLookupStage.php +++ b/src/Builder/Stage/GraphLookupStage.php @@ -28,8 +28,9 @@ * Performs a recursive search on a collection. To each output document, adds a new array field that contains the traversal results of the recursive search for that document. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/ + * @internal */ -class GraphLookupStage implements StageInterface, OperatorInterface +final class GraphLookupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/GroupStage.php b/src/Builder/Stage/GroupStage.php index ea0c8b4b4..8f852a47d 100644 --- a/src/Builder/Stage/GroupStage.php +++ b/src/Builder/Stage/GroupStage.php @@ -25,8 +25,9 @@ * 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. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/ + * @internal */ -class GroupStage implements StageInterface, OperatorInterface +final class GroupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['_id' => '_id', 'field' => null]; diff --git a/src/Builder/Stage/IndexStatsStage.php b/src/Builder/Stage/IndexStatsStage.php index 4fca140bb..752ced1cd 100644 --- a/src/Builder/Stage/IndexStatsStage.php +++ b/src/Builder/Stage/IndexStatsStage.php @@ -16,8 +16,9 @@ * Returns statistics regarding the use of each index for the collection. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/ + * @internal */ -class IndexStatsStage implements StageInterface, OperatorInterface +final class IndexStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/LimitStage.php b/src/Builder/Stage/LimitStage.php index af3052de6..b5f69f76a 100644 --- a/src/Builder/Stage/LimitStage.php +++ b/src/Builder/Stage/LimitStage.php @@ -16,8 +16,9 @@ * Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/ + * @internal */ -class LimitStage implements StageInterface, OperatorInterface +final class LimitStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['limit' => 'limit']; diff --git a/src/Builder/Stage/ListLocalSessionsStage.php b/src/Builder/Stage/ListLocalSessionsStage.php index bb6c8e236..4e7ee9d34 100644 --- a/src/Builder/Stage/ListLocalSessionsStage.php +++ b/src/Builder/Stage/ListLocalSessionsStage.php @@ -23,8 +23,9 @@ * Lists all active sessions recently in use on the currently connected mongos or mongod instance. These sessions may have not yet propagated to the system.sessions collection. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/ + * @internal */ -class ListLocalSessionsStage implements StageInterface, OperatorInterface +final class ListLocalSessionsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['users' => 'users', 'allUsers' => 'allUsers']; diff --git a/src/Builder/Stage/ListSampledQueriesStage.php b/src/Builder/Stage/ListSampledQueriesStage.php index a45a614c5..dc8ec2aa8 100644 --- a/src/Builder/Stage/ListSampledQueriesStage.php +++ b/src/Builder/Stage/ListSampledQueriesStage.php @@ -17,8 +17,9 @@ * Lists sampled queries for all collections or a specific collection. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/ + * @internal */ -class ListSampledQueriesStage implements StageInterface, OperatorInterface +final class ListSampledQueriesStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['namespace' => 'namespace']; diff --git a/src/Builder/Stage/ListSearchIndexesStage.php b/src/Builder/Stage/ListSearchIndexesStage.php index ec4b044ac..e6c48bdfb 100644 --- a/src/Builder/Stage/ListSearchIndexesStage.php +++ b/src/Builder/Stage/ListSearchIndexesStage.php @@ -17,8 +17,9 @@ * Returns information about existing Atlas Search indexes on a specified collection. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/ + * @internal */ -class ListSearchIndexesStage implements StageInterface, OperatorInterface +final class ListSearchIndexesStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['id' => 'id', 'name' => 'name']; diff --git a/src/Builder/Stage/ListSessionsStage.php b/src/Builder/Stage/ListSessionsStage.php index 96bbe4ebd..c242e0166 100644 --- a/src/Builder/Stage/ListSessionsStage.php +++ b/src/Builder/Stage/ListSessionsStage.php @@ -23,8 +23,9 @@ * Lists all sessions that have been active long enough to propagate to the system.sessions collection. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/ + * @internal */ -class ListSessionsStage implements StageInterface, OperatorInterface +final class ListSessionsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['users' => 'users', 'allUsers' => 'allUsers']; diff --git a/src/Builder/Stage/LookupStage.php b/src/Builder/Stage/LookupStage.php index a42166468..85226c2b6 100644 --- a/src/Builder/Stage/LookupStage.php +++ b/src/Builder/Stage/LookupStage.php @@ -27,8 +27,9 @@ * Performs a left outer join to another collection in the same database to filter in documents from the "joined" collection for processing. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/ + * @internal */ -class LookupStage implements StageInterface, OperatorInterface +final class LookupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/MatchStage.php b/src/Builder/Stage/MatchStage.php index 36c827831..85273f057 100644 --- a/src/Builder/Stage/MatchStage.php +++ b/src/Builder/Stage/MatchStage.php @@ -20,8 +20,9 @@ * Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/ + * @internal */ -class MatchStage implements StageInterface, OperatorInterface +final class MatchStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['query' => 'query']; diff --git a/src/Builder/Stage/MergeStage.php b/src/Builder/Stage/MergeStage.php index 6d00416c2..a1994ff13 100644 --- a/src/Builder/Stage/MergeStage.php +++ b/src/Builder/Stage/MergeStage.php @@ -28,8 +28,9 @@ * New in MongoDB 4.2. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/ + * @internal */ -class MergeStage implements StageInterface, OperatorInterface +final class MergeStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/OutStage.php b/src/Builder/Stage/OutStage.php index 7bad49b83..e155d060f 100644 --- a/src/Builder/Stage/OutStage.php +++ b/src/Builder/Stage/OutStage.php @@ -19,8 +19,9 @@ * Writes the resulting documents of the aggregation pipeline to a collection. To use the $out stage, it must be the last stage in the pipeline. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/ + * @internal */ -class OutStage implements StageInterface, OperatorInterface +final class OutStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['coll' => 'coll']; diff --git a/src/Builder/Stage/PlanCacheStatsStage.php b/src/Builder/Stage/PlanCacheStatsStage.php index 98755095f..315b17327 100644 --- a/src/Builder/Stage/PlanCacheStatsStage.php +++ b/src/Builder/Stage/PlanCacheStatsStage.php @@ -16,8 +16,9 @@ * Returns plan cache information for a collection. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/ + * @internal */ -class PlanCacheStatsStage implements StageInterface, OperatorInterface +final class PlanCacheStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/ProjectStage.php b/src/Builder/Stage/ProjectStage.php index 0a9944900..a836114aa 100644 --- a/src/Builder/Stage/ProjectStage.php +++ b/src/Builder/Stage/ProjectStage.php @@ -22,8 +22,9 @@ * Reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/ + * @internal */ -class ProjectStage implements StageInterface, OperatorInterface +final class ProjectStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['specification' => 'specification']; diff --git a/src/Builder/Stage/RedactStage.php b/src/Builder/Stage/RedactStage.php index d6bb6a33d..6c56828b8 100644 --- a/src/Builder/Stage/RedactStage.php +++ b/src/Builder/Stage/RedactStage.php @@ -19,8 +19,9 @@ * Reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves. Incorporates the functionality of $project and $match. Can be used to implement field level redaction. For each input document, outputs either one or zero documents. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/ + * @internal */ -class RedactStage implements StageInterface, OperatorInterface +final class RedactStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Stage/ReplaceRootStage.php b/src/Builder/Stage/ReplaceRootStage.php index abf5ef38b..8e9fe719c 100644 --- a/src/Builder/Stage/ReplaceRootStage.php +++ b/src/Builder/Stage/ReplaceRootStage.php @@ -20,8 +20,9 @@ * Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/ + * @internal */ -class ReplaceRootStage implements StageInterface, OperatorInterface +final class ReplaceRootStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['newRoot' => 'newRoot']; diff --git a/src/Builder/Stage/ReplaceWithStage.php b/src/Builder/Stage/ReplaceWithStage.php index 72bb85cb2..d320af933 100644 --- a/src/Builder/Stage/ReplaceWithStage.php +++ b/src/Builder/Stage/ReplaceWithStage.php @@ -21,8 +21,9 @@ * Alias for $replaceRoot. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/ + * @internal */ -class ReplaceWithStage implements StageInterface, OperatorInterface +final class ReplaceWithStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Stage/SampleStage.php b/src/Builder/Stage/SampleStage.php index 8ac8a9f4f..fd0cb4ed4 100644 --- a/src/Builder/Stage/SampleStage.php +++ b/src/Builder/Stage/SampleStage.php @@ -16,8 +16,9 @@ * Randomly selects the specified number of documents from its input. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/ + * @internal */ -class SampleStage implements StageInterface, OperatorInterface +final class SampleStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['size' => 'size']; diff --git a/src/Builder/Stage/SearchMetaStage.php b/src/Builder/Stage/SearchMetaStage.php index 7f40dff57..579cb4cb4 100644 --- a/src/Builder/Stage/SearchMetaStage.php +++ b/src/Builder/Stage/SearchMetaStage.php @@ -20,8 +20,9 @@ * NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/ + * @internal */ -class SearchMetaStage implements StageInterface, OperatorInterface +final class SearchMetaStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['meta' => 'meta']; diff --git a/src/Builder/Stage/SearchStage.php b/src/Builder/Stage/SearchStage.php index 7f51b7e56..60bdceb4f 100644 --- a/src/Builder/Stage/SearchStage.php +++ b/src/Builder/Stage/SearchStage.php @@ -20,8 +20,9 @@ * NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/ + * @internal */ -class SearchStage implements StageInterface, OperatorInterface +final class SearchStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['search' => 'search']; diff --git a/src/Builder/Stage/SetStage.php b/src/Builder/Stage/SetStage.php index 01c6722f8..534955887 100644 --- a/src/Builder/Stage/SetStage.php +++ b/src/Builder/Stage/SetStage.php @@ -23,8 +23,9 @@ * Alias for $addFields. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/ + * @internal */ -class SetStage implements StageInterface, OperatorInterface +final class SetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['field' => 'field']; diff --git a/src/Builder/Stage/SetWindowFieldsStage.php b/src/Builder/Stage/SetWindowFieldsStage.php index 19fff4059..9e5d43d46 100644 --- a/src/Builder/Stage/SetWindowFieldsStage.php +++ b/src/Builder/Stage/SetWindowFieldsStage.php @@ -23,8 +23,9 @@ * New in MongoDB 5.0. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/ + * @internal */ -class SetWindowFieldsStage implements StageInterface, OperatorInterface +final class SetWindowFieldsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output', 'partitionBy' => 'partitionBy']; diff --git a/src/Builder/Stage/ShardedDataDistributionStage.php b/src/Builder/Stage/ShardedDataDistributionStage.php index de3c3f3a0..ebfaa912e 100644 --- a/src/Builder/Stage/ShardedDataDistributionStage.php +++ b/src/Builder/Stage/ShardedDataDistributionStage.php @@ -17,8 +17,9 @@ * New in MongoDB 6.0.3. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/ + * @internal */ -class ShardedDataDistributionStage implements StageInterface, OperatorInterface +final class ShardedDataDistributionStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Stage/SkipStage.php b/src/Builder/Stage/SkipStage.php index c6e8e9746..66d49e442 100644 --- a/src/Builder/Stage/SkipStage.php +++ b/src/Builder/Stage/SkipStage.php @@ -16,8 +16,9 @@ * Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents). * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/ + * @internal */ -class SkipStage implements StageInterface, OperatorInterface +final class SkipStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['skip' => 'skip']; diff --git a/src/Builder/Stage/SortByCountStage.php b/src/Builder/Stage/SortByCountStage.php index 0e22051ab..8121a900f 100644 --- a/src/Builder/Stage/SortByCountStage.php +++ b/src/Builder/Stage/SortByCountStage.php @@ -19,8 +19,9 @@ * Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/ + * @internal */ -class SortByCountStage implements StageInterface, OperatorInterface +final class SortByCountStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['expression' => 'expression']; diff --git a/src/Builder/Stage/SortStage.php b/src/Builder/Stage/SortStage.php index a707c41e8..311de214b 100644 --- a/src/Builder/Stage/SortStage.php +++ b/src/Builder/Stage/SortStage.php @@ -23,8 +23,9 @@ * Reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/ + * @internal */ -class SortStage implements StageInterface, OperatorInterface +final class SortStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['sort' => 'sort']; diff --git a/src/Builder/Stage/UnionWithStage.php b/src/Builder/Stage/UnionWithStage.php index c3ac7c068..fe96c396b 100644 --- a/src/Builder/Stage/UnionWithStage.php +++ b/src/Builder/Stage/UnionWithStage.php @@ -25,8 +25,9 @@ * New in MongoDB 4.4. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/ + * @internal */ -class UnionWithStage implements StageInterface, OperatorInterface +final class UnionWithStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; public const PROPERTIES = ['coll' => 'coll', 'pipeline' => 'pipeline']; diff --git a/src/Builder/Stage/UnsetStage.php b/src/Builder/Stage/UnsetStage.php index bdf754d88..d84abc2c4 100644 --- a/src/Builder/Stage/UnsetStage.php +++ b/src/Builder/Stage/UnsetStage.php @@ -21,8 +21,9 @@ * Alias for $project stage that removes or excludes fields. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/ + * @internal */ -class UnsetStage implements StageInterface, OperatorInterface +final class UnsetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; public const PROPERTIES = ['field' => 'field']; diff --git a/src/Builder/Stage/UnwindStage.php b/src/Builder/Stage/UnwindStage.php index 39777e109..c9a436891 100644 --- a/src/Builder/Stage/UnwindStage.php +++ b/src/Builder/Stage/UnwindStage.php @@ -18,8 +18,9 @@ * Deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/ + * @internal */ -class UnwindStage implements StageInterface, OperatorInterface +final class UnwindStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; diff --git a/src/Builder/Type/CombinedFieldQuery.php b/src/Builder/Type/CombinedFieldQuery.php index 7619d0ccc..1693c2811 100644 --- a/src/Builder/Type/CombinedFieldQuery.php +++ b/src/Builder/Type/CombinedFieldQuery.php @@ -23,8 +23,10 @@ /** * List of field queries that apply to the same field path. + * + * @internal */ -class CombinedFieldQuery implements FieldQueryInterface +final class CombinedFieldQuery implements FieldQueryInterface { /** @var list $fieldQueries */ public readonly array $fieldQueries; diff --git a/src/Builder/Type/Encode.php b/src/Builder/Type/Encode.php index a4dcfa7e3..792f07e83 100644 --- a/src/Builder/Type/Encode.php +++ b/src/Builder/Type/Encode.php @@ -10,6 +10,7 @@ * Defines how to encode a stage or an operator into BSON. * * @see BuilderEncoder + * @internal */ enum Encode { diff --git a/src/Builder/Type/OutputWindow.php b/src/Builder/Type/OutputWindow.php index 2f6b791a4..72d433ca8 100644 --- a/src/Builder/Type/OutputWindow.php +++ b/src/Builder/Type/OutputWindow.php @@ -23,7 +23,7 @@ * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/ */ -class OutputWindow implements WindowInterface +final class OutputWindow implements WindowInterface { /** * Function used to initialize the state. The init function receives its arguments from the initArgs array expression. From 373bbc4e4aa3d201f31b0d2a81c3ca397110bc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 3 Dec 2024 18:04:09 +0100 Subject: [PATCH 4/5] Replace `OperatorInterface::getOperator()` with `OperatorInterface::NAME` constant (#1541) --- generator/config/expression/case.yaml | 3 ++- generator/config/schema.json | 6 ++++- .../src/Definition/OperatorDefinition.php | 6 ++++- generator/src/OperatorClassGenerator.php | 6 +---- psalm-baseline.xml | 24 +++++++++++++++++++ .../Accumulator/AccumulatorAccumulator.php | 6 +---- .../Accumulator/AddToSetAccumulator.php | 6 +---- src/Builder/Accumulator/AvgAccumulator.php | 6 +---- src/Builder/Accumulator/BottomAccumulator.php | 6 +---- .../Accumulator/BottomNAccumulator.php | 6 +---- src/Builder/Accumulator/CountAccumulator.php | 6 +---- .../Accumulator/CovariancePopAccumulator.php | 6 +---- .../Accumulator/CovarianceSampAccumulator.php | 6 +---- .../Accumulator/DenseRankAccumulator.php | 6 +---- .../Accumulator/DerivativeAccumulator.php | 6 +---- .../Accumulator/DocumentNumberAccumulator.php | 6 +---- .../Accumulator/ExpMovingAvgAccumulator.php | 6 +---- src/Builder/Accumulator/FirstAccumulator.php | 6 +---- src/Builder/Accumulator/FirstNAccumulator.php | 6 +---- .../Accumulator/IntegralAccumulator.php | 6 +---- src/Builder/Accumulator/LastAccumulator.php | 6 +---- src/Builder/Accumulator/LastNAccumulator.php | 6 +---- .../Accumulator/LinearFillAccumulator.php | 6 +---- src/Builder/Accumulator/LocfAccumulator.php | 6 +---- src/Builder/Accumulator/MaxAccumulator.php | 6 +---- src/Builder/Accumulator/MaxNAccumulator.php | 6 +---- src/Builder/Accumulator/MedianAccumulator.php | 6 +---- .../Accumulator/MergeObjectsAccumulator.php | 6 +---- src/Builder/Accumulator/MinAccumulator.php | 6 +---- src/Builder/Accumulator/MinNAccumulator.php | 6 +---- .../Accumulator/PercentileAccumulator.php | 6 +---- src/Builder/Accumulator/PushAccumulator.php | 6 +---- src/Builder/Accumulator/RankAccumulator.php | 6 +---- src/Builder/Accumulator/ShiftAccumulator.php | 6 +---- .../Accumulator/StdDevPopAccumulator.php | 6 +---- .../Accumulator/StdDevSampAccumulator.php | 6 +---- src/Builder/Accumulator/SumAccumulator.php | 6 +---- src/Builder/Accumulator/TopAccumulator.php | 6 +---- src/Builder/Accumulator/TopNAccumulator.php | 6 +---- src/Builder/Encoder/OperatorEncoder.php | 16 +++++++++---- src/Builder/Expression/AbsOperator.php | 6 +---- src/Builder/Expression/AcosOperator.php | 6 +---- src/Builder/Expression/AcoshOperator.php | 6 +---- src/Builder/Expression/AddOperator.php | 6 +---- .../Expression/AllElementsTrueOperator.php | 6 +---- src/Builder/Expression/AndOperator.php | 6 +---- .../Expression/AnyElementTrueOperator.php | 6 +---- .../Expression/ArrayElemAtOperator.php | 6 +---- .../Expression/ArrayToObjectOperator.php | 6 +---- src/Builder/Expression/AsinOperator.php | 6 +---- src/Builder/Expression/AsinhOperator.php | 6 +---- src/Builder/Expression/Atan2Operator.php | 6 +---- src/Builder/Expression/AtanOperator.php | 6 +---- src/Builder/Expression/AtanhOperator.php | 6 +---- src/Builder/Expression/AvgOperator.php | 6 +---- src/Builder/Expression/BinarySizeOperator.php | 6 +---- src/Builder/Expression/BitAndOperator.php | 6 +---- src/Builder/Expression/BitNotOperator.php | 6 +---- src/Builder/Expression/BitOrOperator.php | 6 +---- src/Builder/Expression/BitXorOperator.php | 6 +---- src/Builder/Expression/BsonSizeOperator.php | 6 +---- src/Builder/Expression/CaseOperator.php | 8 ++----- src/Builder/Expression/CeilOperator.php | 6 +---- src/Builder/Expression/CmpOperator.php | 6 +---- .../Expression/ConcatArraysOperator.php | 6 +---- src/Builder/Expression/ConcatOperator.php | 6 +---- src/Builder/Expression/CondOperator.php | 6 +---- src/Builder/Expression/ConvertOperator.php | 6 +---- src/Builder/Expression/CosOperator.php | 6 +---- src/Builder/Expression/CoshOperator.php | 6 +---- src/Builder/Expression/DateAddOperator.php | 6 +---- src/Builder/Expression/DateDiffOperator.php | 6 +---- .../Expression/DateFromPartsOperator.php | 6 +---- .../Expression/DateFromStringOperator.php | 6 +---- .../Expression/DateSubtractOperator.php | 6 +---- .../Expression/DateToPartsOperator.php | 6 +---- .../Expression/DateToStringOperator.php | 6 +---- src/Builder/Expression/DateTruncOperator.php | 6 +---- src/Builder/Expression/DayOfMonthOperator.php | 6 +---- src/Builder/Expression/DayOfWeekOperator.php | 6 +---- src/Builder/Expression/DayOfYearOperator.php | 6 +---- .../Expression/DegreesToRadiansOperator.php | 6 +---- src/Builder/Expression/DivideOperator.php | 6 +---- src/Builder/Expression/EqOperator.php | 6 +---- src/Builder/Expression/ExpOperator.php | 6 +---- src/Builder/Expression/FilterOperator.php | 6 +---- src/Builder/Expression/FirstNOperator.php | 6 +---- src/Builder/Expression/FirstOperator.php | 6 +---- src/Builder/Expression/FloorOperator.php | 6 +---- src/Builder/Expression/FunctionOperator.php | 6 +---- src/Builder/Expression/GetFieldOperator.php | 6 +---- src/Builder/Expression/GtOperator.php | 6 +---- src/Builder/Expression/GteOperator.php | 6 +---- src/Builder/Expression/HourOperator.php | 6 +---- src/Builder/Expression/IfNullOperator.php | 6 +---- src/Builder/Expression/InOperator.php | 6 +---- .../Expression/IndexOfArrayOperator.php | 6 +---- .../Expression/IndexOfBytesOperator.php | 6 +---- src/Builder/Expression/IndexOfCPOperator.php | 6 +---- src/Builder/Expression/IsArrayOperator.php | 6 +---- src/Builder/Expression/IsNumberOperator.php | 6 +---- .../Expression/IsoDayOfWeekOperator.php | 6 +---- src/Builder/Expression/IsoWeekOperator.php | 6 +---- .../Expression/IsoWeekYearOperator.php | 6 +---- src/Builder/Expression/LastNOperator.php | 6 +---- src/Builder/Expression/LastOperator.php | 6 +---- src/Builder/Expression/LetOperator.php | 6 +---- src/Builder/Expression/LiteralOperator.php | 6 +---- src/Builder/Expression/LnOperator.php | 6 +---- src/Builder/Expression/Log10Operator.php | 6 +---- src/Builder/Expression/LogOperator.php | 6 +---- src/Builder/Expression/LtOperator.php | 6 +---- src/Builder/Expression/LteOperator.php | 6 +---- src/Builder/Expression/LtrimOperator.php | 6 +---- src/Builder/Expression/MapOperator.php | 6 +---- src/Builder/Expression/MaxNOperator.php | 6 +---- src/Builder/Expression/MaxOperator.php | 6 +---- src/Builder/Expression/MedianOperator.php | 6 +---- .../Expression/MergeObjectsOperator.php | 6 +---- src/Builder/Expression/MetaOperator.php | 6 +---- .../Expression/MillisecondOperator.php | 6 +---- src/Builder/Expression/MinNOperator.php | 6 +---- src/Builder/Expression/MinOperator.php | 6 +---- src/Builder/Expression/MinuteOperator.php | 6 +---- src/Builder/Expression/ModOperator.php | 6 +---- src/Builder/Expression/MonthOperator.php | 6 +---- src/Builder/Expression/MultiplyOperator.php | 6 +---- src/Builder/Expression/NeOperator.php | 6 +---- src/Builder/Expression/NotOperator.php | 6 +---- .../Expression/ObjectToArrayOperator.php | 6 +---- src/Builder/Expression/OrOperator.php | 6 +---- src/Builder/Expression/PercentileOperator.php | 6 +---- src/Builder/Expression/PowOperator.php | 6 +---- .../Expression/RadiansToDegreesOperator.php | 6 +---- src/Builder/Expression/RandOperator.php | 6 +---- src/Builder/Expression/RangeOperator.php | 6 +---- src/Builder/Expression/ReduceOperator.php | 6 +---- .../Expression/RegexFindAllOperator.php | 6 +---- src/Builder/Expression/RegexFindOperator.php | 6 +---- src/Builder/Expression/RegexMatchOperator.php | 6 +---- src/Builder/Expression/ReplaceAllOperator.php | 6 +---- src/Builder/Expression/ReplaceOneOperator.php | 6 +---- .../Expression/ReverseArrayOperator.php | 6 +---- src/Builder/Expression/RoundOperator.php | 6 +---- src/Builder/Expression/RtrimOperator.php | 6 +---- src/Builder/Expression/SecondOperator.php | 6 +---- .../Expression/SetDifferenceOperator.php | 6 +---- src/Builder/Expression/SetEqualsOperator.php | 6 +---- src/Builder/Expression/SetFieldOperator.php | 6 +---- .../Expression/SetIntersectionOperator.php | 6 +---- .../Expression/SetIsSubsetOperator.php | 6 +---- src/Builder/Expression/SetUnionOperator.php | 6 +---- src/Builder/Expression/SinOperator.php | 6 +---- src/Builder/Expression/SinhOperator.php | 6 +---- src/Builder/Expression/SizeOperator.php | 6 +---- src/Builder/Expression/SliceOperator.php | 6 +---- src/Builder/Expression/SortArrayOperator.php | 6 +---- src/Builder/Expression/SplitOperator.php | 6 +---- src/Builder/Expression/SqrtOperator.php | 6 +---- src/Builder/Expression/StdDevPopOperator.php | 6 +---- src/Builder/Expression/StdDevSampOperator.php | 6 +---- .../Expression/StrLenBytesOperator.php | 6 +---- src/Builder/Expression/StrLenCPOperator.php | 6 +---- src/Builder/Expression/StrcasecmpOperator.php | 6 +---- .../Expression/SubstrBytesOperator.php | 6 +---- src/Builder/Expression/SubstrCPOperator.php | 6 +---- src/Builder/Expression/SubstrOperator.php | 6 +---- src/Builder/Expression/SubtractOperator.php | 6 +---- src/Builder/Expression/SumOperator.php | 6 +---- src/Builder/Expression/SwitchOperator.php | 6 +---- src/Builder/Expression/TanOperator.php | 6 +---- src/Builder/Expression/TanhOperator.php | 6 +---- src/Builder/Expression/ToBoolOperator.php | 6 +---- src/Builder/Expression/ToDateOperator.php | 6 +---- src/Builder/Expression/ToDecimalOperator.php | 6 +---- src/Builder/Expression/ToDoubleOperator.php | 6 +---- .../Expression/ToHashedIndexKeyOperator.php | 6 +---- src/Builder/Expression/ToIntOperator.php | 6 +---- src/Builder/Expression/ToLongOperator.php | 6 +---- src/Builder/Expression/ToLowerOperator.php | 6 +---- src/Builder/Expression/ToObjectIdOperator.php | 6 +---- src/Builder/Expression/ToStringOperator.php | 6 +---- src/Builder/Expression/ToUpperOperator.php | 6 +---- src/Builder/Expression/TrimOperator.php | 6 +---- src/Builder/Expression/TruncOperator.php | 6 +---- .../Expression/TsIncrementOperator.php | 6 +---- src/Builder/Expression/TsSecondOperator.php | 6 +---- src/Builder/Expression/TypeOperator.php | 6 +---- src/Builder/Expression/UnsetFieldOperator.php | 6 +---- src/Builder/Expression/WeekOperator.php | 6 +---- src/Builder/Expression/YearOperator.php | 6 +---- src/Builder/Expression/ZipOperator.php | 6 +---- src/Builder/Query/AllOperator.php | 6 +---- src/Builder/Query/AndOperator.php | 6 +---- src/Builder/Query/BitsAllClearOperator.php | 6 +---- src/Builder/Query/BitsAllSetOperator.php | 6 +---- src/Builder/Query/BitsAnyClearOperator.php | 6 +---- src/Builder/Query/BitsAnySetOperator.php | 6 +---- src/Builder/Query/BoxOperator.php | 6 +---- src/Builder/Query/CenterOperator.php | 6 +---- src/Builder/Query/CenterSphereOperator.php | 6 +---- src/Builder/Query/CommentOperator.php | 6 +---- src/Builder/Query/ElemMatchOperator.php | 6 +---- src/Builder/Query/EqOperator.php | 6 +---- src/Builder/Query/ExistsOperator.php | 6 +---- src/Builder/Query/ExprOperator.php | 6 +---- src/Builder/Query/GeoIntersectsOperator.php | 6 +---- src/Builder/Query/GeoWithinOperator.php | 6 +---- src/Builder/Query/GeometryOperator.php | 6 +---- src/Builder/Query/GtOperator.php | 6 +---- src/Builder/Query/GteOperator.php | 6 +---- src/Builder/Query/InOperator.php | 6 +---- src/Builder/Query/JsonSchemaOperator.php | 6 +---- src/Builder/Query/LtOperator.php | 6 +---- src/Builder/Query/LteOperator.php | 6 +---- src/Builder/Query/MaxDistanceOperator.php | 6 +---- src/Builder/Query/MinDistanceOperator.php | 6 +---- src/Builder/Query/ModOperator.php | 6 +---- src/Builder/Query/NeOperator.php | 6 +---- src/Builder/Query/NearOperator.php | 6 +---- src/Builder/Query/NearSphereOperator.php | 6 +---- src/Builder/Query/NinOperator.php | 6 +---- src/Builder/Query/NorOperator.php | 6 +---- src/Builder/Query/NotOperator.php | 6 +---- src/Builder/Query/OrOperator.php | 6 +---- src/Builder/Query/PolygonOperator.php | 6 +---- src/Builder/Query/RandOperator.php | 6 +---- src/Builder/Query/RegexOperator.php | 6 +---- src/Builder/Query/SampleRateOperator.php | 6 +---- src/Builder/Query/SizeOperator.php | 6 +---- src/Builder/Query/TextOperator.php | 6 +---- src/Builder/Query/TypeOperator.php | 6 +---- src/Builder/Query/WhereOperator.php | 6 +---- src/Builder/Stage/AddFieldsStage.php | 6 +---- src/Builder/Stage/BucketAutoStage.php | 6 +---- src/Builder/Stage/BucketStage.php | 6 +---- .../ChangeStreamSplitLargeEventStage.php | 6 +---- src/Builder/Stage/ChangeStreamStage.php | 6 +---- src/Builder/Stage/CollStatsStage.php | 6 +---- src/Builder/Stage/CountStage.php | 6 +---- src/Builder/Stage/CurrentOpStage.php | 6 +---- src/Builder/Stage/DensifyStage.php | 6 +---- src/Builder/Stage/DocumentsStage.php | 6 +---- src/Builder/Stage/FacetStage.php | 6 +---- src/Builder/Stage/FillStage.php | 6 +---- src/Builder/Stage/GeoNearStage.php | 6 +---- src/Builder/Stage/GraphLookupStage.php | 6 +---- src/Builder/Stage/GroupStage.php | 6 +---- src/Builder/Stage/IndexStatsStage.php | 6 +---- src/Builder/Stage/LimitStage.php | 6 +---- src/Builder/Stage/ListLocalSessionsStage.php | 6 +---- src/Builder/Stage/ListSampledQueriesStage.php | 6 +---- src/Builder/Stage/ListSearchIndexesStage.php | 6 +---- src/Builder/Stage/ListSessionsStage.php | 6 +---- src/Builder/Stage/LookupStage.php | 6 +---- src/Builder/Stage/MatchStage.php | 6 +---- src/Builder/Stage/MergeStage.php | 6 +---- src/Builder/Stage/OutStage.php | 6 +---- src/Builder/Stage/PlanCacheStatsStage.php | 6 +---- src/Builder/Stage/ProjectStage.php | 6 +---- src/Builder/Stage/RedactStage.php | 6 +---- src/Builder/Stage/ReplaceRootStage.php | 6 +---- src/Builder/Stage/ReplaceWithStage.php | 6 +---- src/Builder/Stage/SampleStage.php | 6 +---- src/Builder/Stage/SearchMetaStage.php | 6 +---- src/Builder/Stage/SearchStage.php | 6 +---- src/Builder/Stage/SetStage.php | 6 +---- src/Builder/Stage/SetWindowFieldsStage.php | 6 +---- .../Stage/ShardedDataDistributionStage.php | 6 +---- src/Builder/Stage/SkipStage.php | 6 +---- src/Builder/Stage/SortByCountStage.php | 6 +---- src/Builder/Stage/SortStage.php | 6 +---- src/Builder/Stage/UnionWithStage.php | 6 +---- src/Builder/Stage/UnsetStage.php | 6 +---- src/Builder/Stage/UnwindStage.php | 6 +---- src/Builder/Type/CombinedFieldQuery.php | 3 ++- src/Builder/Type/Encode.php | 5 ---- src/Builder/Type/OperatorInterface.php | 3 ++- src/Builder/Type/QueryObject.php | 6 ++--- 279 files changed, 325 insertions(+), 1369 deletions(-) diff --git a/generator/config/expression/case.yaml b/generator/config/expression/case.yaml index b86aef878..ccf463c90 100644 --- a/generator/config/expression/case.yaml +++ b/generator/config/expression/case.yaml @@ -3,7 +3,8 @@ name: $case link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/' type: - switchBranch -encode: flat_object +encode: object +wrapObject: false description: | Represents a single case in a $switch expression arguments: diff --git a/generator/config/schema.json b/generator/config/schema.json index 61846e3e7..8e2f5f320 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -60,7 +60,6 @@ "enum": [ "array", "object", - "flat_object", "single" ] }, @@ -68,6 +67,11 @@ "$comment": "The description of the argument from MongoDB's documentation.", "type": "string" }, + "wrapObject": { + "$comment": "Wrap the properties in an object with the operator name", + "type": "boolean", + "default": true + }, "arguments": { "$comment": "An optional list of arguments for the operator.", "type": "array", diff --git a/generator/src/Definition/OperatorDefinition.php b/generator/src/Definition/OperatorDefinition.php index eb9876239..5468b7917 100644 --- a/generator/src/Definition/OperatorDefinition.php +++ b/generator/src/Definition/OperatorDefinition.php @@ -32,6 +32,7 @@ public function __construct( /** @var list */ public array $type, public string|null $description = null, + public bool $wrapObject = true, array $arguments = [], array $tests = [], ) { @@ -39,10 +40,13 @@ public function __construct( 'single' => Encode::Single, 'array' => Encode::Array, 'object' => Encode::Object, - 'flat_object' => Encode::FlatObject, default => throw new UnexpectedValueException(sprintf('Unexpected "encode" value for operator "%s". Got "%s"', $name, $encode)), }; + if (! $wrapObject && $this->encode !== Encode::Object) { + throw new UnexpectedValueException(sprintf('Operator "%s" cannot have wrapObject set to false when encode is not "object"', $name)); + } + // Convert arguments to ArgumentDefinition objects // Optional arguments must be after required arguments $requiredArgs = $optionalArgs = []; diff --git a/generator/src/OperatorClassGenerator.php b/generator/src/OperatorClassGenerator.php index e51a1979d..7f8667751 100644 --- a/generator/src/OperatorClassGenerator.php +++ b/generator/src/OperatorClassGenerator.php @@ -22,7 +22,6 @@ use function interface_exists; use function rtrim; use function sprintf; -use function var_export; /** * Generates a value object class for stages and operators. @@ -62,6 +61,7 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition $class->addComment('@internal'); $namespace->addUse(Encode::class); $class->addConstant('ENCODE', new Literal('Encode::' . $operator->encode->name)); + $class->addConstant('NAME', $operator->wrapObject ? $operator->name : null); $encodeNames = []; $constructor = $class->addMethod('__construct'); @@ -179,10 +179,6 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition $class->addConstant('PROPERTIES', $encodeNames); } - $class->addMethod('getOperator') - ->setReturnType('string') - ->setBody('return ' . var_export($operator->name, true) . ';'); - return $namespace; } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 4d703d593..301c049ac 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -172,7 +172,26 @@ + + + + + + + + + + + + + + + + + + + @@ -183,6 +202,11 @@ is_array($queriesOrArrayOfQueries[0]) && count($queriesOrArrayOfQueries[0]) > 0]]> + + + + + diff --git a/src/Builder/Accumulator/AccumulatorAccumulator.php b/src/Builder/Accumulator/AccumulatorAccumulator.php index 6a5cdd06b..a49390fd6 100644 --- a/src/Builder/Accumulator/AccumulatorAccumulator.php +++ b/src/Builder/Accumulator/AccumulatorAccumulator.php @@ -32,6 +32,7 @@ final class AccumulatorAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$accumulator'; public const PROPERTIES = [ 'init' => 'init', @@ -114,9 +115,4 @@ public function __construct( $this->finalize = $finalize; } - - public function getOperator(): string - { - return '$accumulator'; - } } diff --git a/src/Builder/Accumulator/AddToSetAccumulator.php b/src/Builder/Accumulator/AddToSetAccumulator.php index 70be4bdbe..2c77a7458 100644 --- a/src/Builder/Accumulator/AddToSetAccumulator.php +++ b/src/Builder/Accumulator/AddToSetAccumulator.php @@ -26,6 +26,7 @@ final class AddToSetAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$addToSet'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$addToSet'; - } } diff --git a/src/Builder/Accumulator/AvgAccumulator.php b/src/Builder/Accumulator/AvgAccumulator.php index 034fa776b..4b9050117 100644 --- a/src/Builder/Accumulator/AvgAccumulator.php +++ b/src/Builder/Accumulator/AvgAccumulator.php @@ -26,6 +26,7 @@ final class AvgAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$avg'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$avg'; - } } diff --git a/src/Builder/Accumulator/BottomAccumulator.php b/src/Builder/Accumulator/BottomAccumulator.php index f001d6e04..eecf0a013 100644 --- a/src/Builder/Accumulator/BottomAccumulator.php +++ b/src/Builder/Accumulator/BottomAccumulator.php @@ -28,6 +28,7 @@ final class BottomAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$bottom'; public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output']; /** @var Document|Serializable|array|stdClass $sortBy Specifies the order of results, with syntax similar to $sort. */ @@ -47,9 +48,4 @@ public function __construct( $this->sortBy = $sortBy; $this->output = $output; } - - public function getOperator(): string - { - return '$bottom'; - } } diff --git a/src/Builder/Accumulator/BottomNAccumulator.php b/src/Builder/Accumulator/BottomNAccumulator.php index 4e2f5705c..94911d25e 100644 --- a/src/Builder/Accumulator/BottomNAccumulator.php +++ b/src/Builder/Accumulator/BottomNAccumulator.php @@ -30,6 +30,7 @@ final class BottomNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$bottomN'; 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. */ @@ -55,9 +56,4 @@ public function __construct( $this->sortBy = $sortBy; $this->output = $output; } - - public function getOperator(): string - { - return '$bottomN'; - } } diff --git a/src/Builder/Accumulator/CountAccumulator.php b/src/Builder/Accumulator/CountAccumulator.php index 699eedc16..933d86c6d 100644 --- a/src/Builder/Accumulator/CountAccumulator.php +++ b/src/Builder/Accumulator/CountAccumulator.php @@ -24,13 +24,9 @@ final class CountAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$count'; public function __construct() { } - - public function getOperator(): string - { - return '$count'; - } } diff --git a/src/Builder/Accumulator/CovariancePopAccumulator.php b/src/Builder/Accumulator/CovariancePopAccumulator.php index f23170329..d9bd9173e 100644 --- a/src/Builder/Accumulator/CovariancePopAccumulator.php +++ b/src/Builder/Accumulator/CovariancePopAccumulator.php @@ -25,6 +25,7 @@ final class CovariancePopAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$covariancePop'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression1 */ @@ -44,9 +45,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$covariancePop'; - } } diff --git a/src/Builder/Accumulator/CovarianceSampAccumulator.php b/src/Builder/Accumulator/CovarianceSampAccumulator.php index b99d1cdda..85ba2cf28 100644 --- a/src/Builder/Accumulator/CovarianceSampAccumulator.php +++ b/src/Builder/Accumulator/CovarianceSampAccumulator.php @@ -25,6 +25,7 @@ final class CovarianceSampAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$covarianceSamp'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression1 */ @@ -44,9 +45,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$covarianceSamp'; - } } diff --git a/src/Builder/Accumulator/DenseRankAccumulator.php b/src/Builder/Accumulator/DenseRankAccumulator.php index 820a9fe36..c5bc4bee9 100644 --- a/src/Builder/Accumulator/DenseRankAccumulator.php +++ b/src/Builder/Accumulator/DenseRankAccumulator.php @@ -22,13 +22,9 @@ final class DenseRankAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$denseRank'; public function __construct() { } - - public function getOperator(): string - { - return '$denseRank'; - } } diff --git a/src/Builder/Accumulator/DerivativeAccumulator.php b/src/Builder/Accumulator/DerivativeAccumulator.php index 80b111a2d..9ede80357 100644 --- a/src/Builder/Accumulator/DerivativeAccumulator.php +++ b/src/Builder/Accumulator/DerivativeAccumulator.php @@ -30,6 +30,7 @@ final class DerivativeAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$derivative'; public const PROPERTIES = ['input' => 'input', 'unit' => 'unit']; /** @var Decimal128|Int64|ResolvesToDate|ResolvesToNumber|UTCDateTime|float|int $input */ @@ -53,9 +54,4 @@ public function __construct( $this->input = $input; $this->unit = $unit; } - - public function getOperator(): string - { - return '$derivative'; - } } diff --git a/src/Builder/Accumulator/DocumentNumberAccumulator.php b/src/Builder/Accumulator/DocumentNumberAccumulator.php index ae776659e..a44f63475 100644 --- a/src/Builder/Accumulator/DocumentNumberAccumulator.php +++ b/src/Builder/Accumulator/DocumentNumberAccumulator.php @@ -22,13 +22,9 @@ final class DocumentNumberAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$documentNumber'; public function __construct() { } - - public function getOperator(): string - { - return '$documentNumber'; - } } diff --git a/src/Builder/Accumulator/ExpMovingAvgAccumulator.php b/src/Builder/Accumulator/ExpMovingAvgAccumulator.php index 44999b734..2bfe285f8 100644 --- a/src/Builder/Accumulator/ExpMovingAvgAccumulator.php +++ b/src/Builder/Accumulator/ExpMovingAvgAccumulator.php @@ -26,6 +26,7 @@ final class ExpMovingAvgAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$expMovingAvg'; public const PROPERTIES = ['input' => 'input', 'N' => 'N', 'alpha' => 'alpha']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $input */ @@ -61,9 +62,4 @@ public function __construct( $this->N = $N; $this->alpha = $alpha; } - - public function getOperator(): string - { - return '$expMovingAvg'; - } } diff --git a/src/Builder/Accumulator/FirstAccumulator.php b/src/Builder/Accumulator/FirstAccumulator.php index 2e4ff57ae..20e3b4ee2 100644 --- a/src/Builder/Accumulator/FirstAccumulator.php +++ b/src/Builder/Accumulator/FirstAccumulator.php @@ -26,6 +26,7 @@ final class FirstAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$first'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$first'; - } } diff --git a/src/Builder/Accumulator/FirstNAccumulator.php b/src/Builder/Accumulator/FirstNAccumulator.php index 844a9ff9f..740ebc7ae 100644 --- a/src/Builder/Accumulator/FirstNAccumulator.php +++ b/src/Builder/Accumulator/FirstNAccumulator.php @@ -28,6 +28,7 @@ final class FirstNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$firstN'; 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. */ @@ -47,9 +48,4 @@ public function __construct( $this->input = $input; $this->n = $n; } - - public function getOperator(): string - { - return '$firstN'; - } } diff --git a/src/Builder/Accumulator/IntegralAccumulator.php b/src/Builder/Accumulator/IntegralAccumulator.php index 3255fc328..be34f57a2 100644 --- a/src/Builder/Accumulator/IntegralAccumulator.php +++ b/src/Builder/Accumulator/IntegralAccumulator.php @@ -30,6 +30,7 @@ final class IntegralAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$integral'; public const PROPERTIES = ['input' => 'input', 'unit' => 'unit']; /** @var Decimal128|Int64|ResolvesToDate|ResolvesToNumber|UTCDateTime|float|int $input */ @@ -53,9 +54,4 @@ public function __construct( $this->input = $input; $this->unit = $unit; } - - public function getOperator(): string - { - return '$integral'; - } } diff --git a/src/Builder/Accumulator/LastAccumulator.php b/src/Builder/Accumulator/LastAccumulator.php index b568fe77c..dd495538a 100644 --- a/src/Builder/Accumulator/LastAccumulator.php +++ b/src/Builder/Accumulator/LastAccumulator.php @@ -26,6 +26,7 @@ final class LastAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$last'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$last'; - } } diff --git a/src/Builder/Accumulator/LastNAccumulator.php b/src/Builder/Accumulator/LastNAccumulator.php index 75fa90c36..c0ddbd9bb 100644 --- a/src/Builder/Accumulator/LastNAccumulator.php +++ b/src/Builder/Accumulator/LastNAccumulator.php @@ -32,6 +32,7 @@ final class LastNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$lastN'; 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. */ @@ -53,9 +54,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $input, $this->input = $input; $this->n = $n; } - - public function getOperator(): string - { - return '$lastN'; - } } diff --git a/src/Builder/Accumulator/LinearFillAccumulator.php b/src/Builder/Accumulator/LinearFillAccumulator.php index 3ca8f52c6..59aade4a1 100644 --- a/src/Builder/Accumulator/LinearFillAccumulator.php +++ b/src/Builder/Accumulator/LinearFillAccumulator.php @@ -26,6 +26,7 @@ final class LinearFillAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$linearFill'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$linearFill'; - } } diff --git a/src/Builder/Accumulator/LocfAccumulator.php b/src/Builder/Accumulator/LocfAccumulator.php index 0ecc6002a..15ee21740 100644 --- a/src/Builder/Accumulator/LocfAccumulator.php +++ b/src/Builder/Accumulator/LocfAccumulator.php @@ -26,6 +26,7 @@ final class LocfAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$locf'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$locf'; - } } diff --git a/src/Builder/Accumulator/MaxAccumulator.php b/src/Builder/Accumulator/MaxAccumulator.php index 3eaf66b3c..cf53cb8cd 100644 --- a/src/Builder/Accumulator/MaxAccumulator.php +++ b/src/Builder/Accumulator/MaxAccumulator.php @@ -26,6 +26,7 @@ final class MaxAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$max'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$max'; - } } diff --git a/src/Builder/Accumulator/MaxNAccumulator.php b/src/Builder/Accumulator/MaxNAccumulator.php index 01f2a3430..04530f24e 100644 --- a/src/Builder/Accumulator/MaxNAccumulator.php +++ b/src/Builder/Accumulator/MaxNAccumulator.php @@ -30,6 +30,7 @@ final class MaxNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$maxN'; 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. */ @@ -51,9 +52,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $input, $this->input = $input; $this->n = $n; } - - public function getOperator(): string - { - return '$maxN'; - } } diff --git a/src/Builder/Accumulator/MedianAccumulator.php b/src/Builder/Accumulator/MedianAccumulator.php index 83e32ea15..358be201b 100644 --- a/src/Builder/Accumulator/MedianAccumulator.php +++ b/src/Builder/Accumulator/MedianAccumulator.php @@ -30,6 +30,7 @@ final class MedianAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$median'; 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. */ @@ -47,9 +48,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $input, $this->input = $input; $this->method = $method; } - - public function getOperator(): string - { - return '$median'; - } } diff --git a/src/Builder/Accumulator/MergeObjectsAccumulator.php b/src/Builder/Accumulator/MergeObjectsAccumulator.php index 0c4e1737c..87a8e6a00 100644 --- a/src/Builder/Accumulator/MergeObjectsAccumulator.php +++ b/src/Builder/Accumulator/MergeObjectsAccumulator.php @@ -25,6 +25,7 @@ final class MergeObjectsAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$mergeObjects'; public const PROPERTIES = ['document' => 'document']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $document Any valid expression that resolves to a document. */ @@ -37,9 +38,4 @@ public function __construct(Document|Serializable|ResolvesToObject|stdClass|arra { $this->document = $document; } - - public function getOperator(): string - { - return '$mergeObjects'; - } } diff --git a/src/Builder/Accumulator/MinAccumulator.php b/src/Builder/Accumulator/MinAccumulator.php index c2536772b..b90ef761b 100644 --- a/src/Builder/Accumulator/MinAccumulator.php +++ b/src/Builder/Accumulator/MinAccumulator.php @@ -26,6 +26,7 @@ final class MinAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$min'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$min'; - } } diff --git a/src/Builder/Accumulator/MinNAccumulator.php b/src/Builder/Accumulator/MinNAccumulator.php index 997859098..7a7dbcb37 100644 --- a/src/Builder/Accumulator/MinNAccumulator.php +++ b/src/Builder/Accumulator/MinNAccumulator.php @@ -30,6 +30,7 @@ final class MinNAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$minN'; 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. */ @@ -51,9 +52,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $input, $this->input = $input; $this->n = $n; } - - public function getOperator(): string - { - return '$minN'; - } } diff --git a/src/Builder/Accumulator/PercentileAccumulator.php b/src/Builder/Accumulator/PercentileAccumulator.php index a8d254ee1..3766d8f1d 100644 --- a/src/Builder/Accumulator/PercentileAccumulator.php +++ b/src/Builder/Accumulator/PercentileAccumulator.php @@ -40,6 +40,7 @@ final class PercentileAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$percentile'; 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. */ @@ -73,9 +74,4 @@ public function __construct( $this->p = $p; $this->method = $method; } - - public function getOperator(): string - { - return '$percentile'; - } } diff --git a/src/Builder/Accumulator/PushAccumulator.php b/src/Builder/Accumulator/PushAccumulator.php index 85a4282f5..8f04023a9 100644 --- a/src/Builder/Accumulator/PushAccumulator.php +++ b/src/Builder/Accumulator/PushAccumulator.php @@ -26,6 +26,7 @@ final class PushAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$push'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -38,9 +39,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$push'; - } } diff --git a/src/Builder/Accumulator/RankAccumulator.php b/src/Builder/Accumulator/RankAccumulator.php index 9fea2d1f8..ddf2f665c 100644 --- a/src/Builder/Accumulator/RankAccumulator.php +++ b/src/Builder/Accumulator/RankAccumulator.php @@ -22,13 +22,9 @@ final class RankAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$rank'; public function __construct() { } - - public function getOperator(): string - { - return '$rank'; - } } diff --git a/src/Builder/Accumulator/ShiftAccumulator.php b/src/Builder/Accumulator/ShiftAccumulator.php index 85b39591b..5f4200307 100644 --- a/src/Builder/Accumulator/ShiftAccumulator.php +++ b/src/Builder/Accumulator/ShiftAccumulator.php @@ -25,6 +25,7 @@ final class ShiftAccumulator implements WindowInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$shift'; 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. */ @@ -66,9 +67,4 @@ public function __construct( $this->by = $by; $this->default = $default; } - - public function getOperator(): string - { - return '$shift'; - } } diff --git a/src/Builder/Accumulator/StdDevPopAccumulator.php b/src/Builder/Accumulator/StdDevPopAccumulator.php index faeeaf301..efa166707 100644 --- a/src/Builder/Accumulator/StdDevPopAccumulator.php +++ b/src/Builder/Accumulator/StdDevPopAccumulator.php @@ -27,6 +27,7 @@ final class StdDevPopAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$stdDevPop'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -39,9 +40,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$stdDevPop'; - } } diff --git a/src/Builder/Accumulator/StdDevSampAccumulator.php b/src/Builder/Accumulator/StdDevSampAccumulator.php index e4a177636..d02f9e485 100644 --- a/src/Builder/Accumulator/StdDevSampAccumulator.php +++ b/src/Builder/Accumulator/StdDevSampAccumulator.php @@ -27,6 +27,7 @@ final class StdDevSampAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$stdDevSamp'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -39,9 +40,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$stdDevSamp'; - } } diff --git a/src/Builder/Accumulator/SumAccumulator.php b/src/Builder/Accumulator/SumAccumulator.php index a2ad7af00..172915e2c 100644 --- a/src/Builder/Accumulator/SumAccumulator.php +++ b/src/Builder/Accumulator/SumAccumulator.php @@ -26,6 +26,7 @@ final class SumAccumulator implements AccumulatorInterface, WindowInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sum'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$sum'; - } } diff --git a/src/Builder/Accumulator/TopAccumulator.php b/src/Builder/Accumulator/TopAccumulator.php index efad91414..7fac97efc 100644 --- a/src/Builder/Accumulator/TopAccumulator.php +++ b/src/Builder/Accumulator/TopAccumulator.php @@ -29,6 +29,7 @@ final class TopAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$top'; public const PROPERTIES = ['sortBy' => 'sortBy', 'output' => 'output']; /** @var Document|Serializable|array|stdClass $sortBy Specifies the order of results, with syntax similar to $sort. */ @@ -48,9 +49,4 @@ public function __construct( $this->sortBy = $sortBy; $this->output = $output; } - - public function getOperator(): string - { - return '$top'; - } } diff --git a/src/Builder/Accumulator/TopNAccumulator.php b/src/Builder/Accumulator/TopNAccumulator.php index ffcca2872..ea0ae9bc0 100644 --- a/src/Builder/Accumulator/TopNAccumulator.php +++ b/src/Builder/Accumulator/TopNAccumulator.php @@ -30,6 +30,7 @@ final class TopNAccumulator implements AccumulatorInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$topN'; 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. */ @@ -55,9 +56,4 @@ public function __construct( $this->sortBy = $sortBy; $this->output = $output; } - - public function getOperator(): string - { - return '$topN'; - } } diff --git a/src/Builder/Encoder/OperatorEncoder.php b/src/Builder/Encoder/OperatorEncoder.php index ddc49faab..5c18d7c0b 100644 --- a/src/Builder/Encoder/OperatorEncoder.php +++ b/src/Builder/Encoder/OperatorEncoder.php @@ -12,6 +12,8 @@ use MongoDB\Exception\UnsupportedValueException; use stdClass; +use function assert; +use function is_string; use function sprintf; /** @@ -37,7 +39,7 @@ public function encode(mixed $value): stdClass return match ($value::ENCODE) { Encode::Single => $this->encodeAsSingle($value), Encode::Array => $this->encodeAsArray($value), - Encode::Object, Encode::FlatObject => $this->encodeAsObject($value), + Encode::Object => $this->encodeAsObject($value), default => throw new LogicException(sprintf('Class "%s" does not have a valid ENCODE constant.', $value::class)), }; } @@ -89,9 +91,11 @@ private function encodeAsObject(OperatorInterface $value): stdClass } } - return $value::ENCODE === Encode::FlatObject - ? $result - : $this->wrap($value, $result); + if ($value::NAME === null) { + return $result; + } + + return $this->wrap($value, $result); } /** @@ -110,8 +114,10 @@ private function encodeAsSingle(OperatorInterface $value): stdClass private function wrap(OperatorInterface $value, mixed $result): stdClass { + assert(is_string($value::NAME)); + $object = new stdClass(); - $object->{$value->getOperator()} = $result; + $object->{$value::NAME} = $result; return $object; } diff --git a/src/Builder/Expression/AbsOperator.php b/src/Builder/Expression/AbsOperator.php index aa0dfc78a..977a05a44 100644 --- a/src/Builder/Expression/AbsOperator.php +++ b/src/Builder/Expression/AbsOperator.php @@ -22,6 +22,7 @@ final class AbsOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$abs'; public const PROPERTIES = ['value' => 'value']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $value */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $value) { $this->value = $value; } - - public function getOperator(): string - { - return '$abs'; - } } diff --git a/src/Builder/Expression/AcosOperator.php b/src/Builder/Expression/AcosOperator.php index 7123b7d25..47ae210d3 100644 --- a/src/Builder/Expression/AcosOperator.php +++ b/src/Builder/Expression/AcosOperator.php @@ -22,6 +22,7 @@ final class AcosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$acos'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$acos'; - } } diff --git a/src/Builder/Expression/AcoshOperator.php b/src/Builder/Expression/AcoshOperator.php index 1715e3a41..8be5bc4a7 100644 --- a/src/Builder/Expression/AcoshOperator.php +++ b/src/Builder/Expression/AcoshOperator.php @@ -22,6 +22,7 @@ final class AcoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$acosh'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$acosh'; - } } diff --git a/src/Builder/Expression/AddOperator.php b/src/Builder/Expression/AddOperator.php index 45e9fa745..259e64b08 100644 --- a/src/Builder/Expression/AddOperator.php +++ b/src/Builder/Expression/AddOperator.php @@ -26,6 +26,7 @@ final class AddOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$add'; 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. */ @@ -47,9 +48,4 @@ public function __construct(Decimal128|Int64|UTCDateTime|ResolvesToDate|Resolves $this->expression = $expression; } - - public function getOperator(): string - { - return '$add'; - } } diff --git a/src/Builder/Expression/AllElementsTrueOperator.php b/src/Builder/Expression/AllElementsTrueOperator.php index 4ac75df9a..dbb74d967 100644 --- a/src/Builder/Expression/AllElementsTrueOperator.php +++ b/src/Builder/Expression/AllElementsTrueOperator.php @@ -26,6 +26,7 @@ final class AllElementsTrueOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$allElementsTrue'; public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $express $this->expression = $expression; } - - public function getOperator(): string - { - return '$allElementsTrue'; - } } diff --git a/src/Builder/Expression/AndOperator.php b/src/Builder/Expression/AndOperator.php index 7334967e5..8e3364ab3 100644 --- a/src/Builder/Expression/AndOperator.php +++ b/src/Builder/Expression/AndOperator.php @@ -28,6 +28,7 @@ final class AndOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$and'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -50,9 +51,4 @@ public function __construct( $this->expression = $expression; } - - public function getOperator(): string - { - return '$and'; - } } diff --git a/src/Builder/Expression/AnyElementTrueOperator.php b/src/Builder/Expression/AnyElementTrueOperator.php index fa0b0a3f7..c8dd665b6 100644 --- a/src/Builder/Expression/AnyElementTrueOperator.php +++ b/src/Builder/Expression/AnyElementTrueOperator.php @@ -26,6 +26,7 @@ final class AnyElementTrueOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$anyElementTrue'; public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $express $this->expression = $expression; } - - public function getOperator(): string - { - return '$anyElementTrue'; - } } diff --git a/src/Builder/Expression/ArrayElemAtOperator.php b/src/Builder/Expression/ArrayElemAtOperator.php index 81cc74497..a5f333359 100644 --- a/src/Builder/Expression/ArrayElemAtOperator.php +++ b/src/Builder/Expression/ArrayElemAtOperator.php @@ -26,6 +26,7 @@ final class ArrayElemAtOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$arrayElemAt'; public const PROPERTIES = ['array' => 'array', 'idx' => 'idx']; /** @var BSONArray|PackedArray|ResolvesToArray|array $array */ @@ -47,9 +48,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $array, $this->array = $array; $this->idx = $idx; } - - public function getOperator(): string - { - return '$arrayElemAt'; - } } diff --git a/src/Builder/Expression/ArrayToObjectOperator.php b/src/Builder/Expression/ArrayToObjectOperator.php index 765923441..657f67676 100644 --- a/src/Builder/Expression/ArrayToObjectOperator.php +++ b/src/Builder/Expression/ArrayToObjectOperator.php @@ -26,6 +26,7 @@ final class ArrayToObjectOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$arrayToObject'; public const PROPERTIES = ['array' => 'array']; /** @var BSONArray|PackedArray|ResolvesToArray|array $array */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $array) $this->array = $array; } - - public function getOperator(): string - { - return '$arrayToObject'; - } } diff --git a/src/Builder/Expression/AsinOperator.php b/src/Builder/Expression/AsinOperator.php index f9c585980..4f9a205e3 100644 --- a/src/Builder/Expression/AsinOperator.php +++ b/src/Builder/Expression/AsinOperator.php @@ -22,6 +22,7 @@ final class AsinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$asin'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$asin'; - } } diff --git a/src/Builder/Expression/AsinhOperator.php b/src/Builder/Expression/AsinhOperator.php index 720c5e20e..4e5c72ef3 100644 --- a/src/Builder/Expression/AsinhOperator.php +++ b/src/Builder/Expression/AsinhOperator.php @@ -22,6 +22,7 @@ final class AsinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$asinh'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$asinh'; - } } diff --git a/src/Builder/Expression/Atan2Operator.php b/src/Builder/Expression/Atan2Operator.php index ae485c994..78f56c8a8 100644 --- a/src/Builder/Expression/Atan2Operator.php +++ b/src/Builder/Expression/Atan2Operator.php @@ -22,6 +22,7 @@ final class Atan2Operator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$atan2'; public const PROPERTIES = ['y' => 'y', 'x' => 'x']; /** @@ -47,9 +48,4 @@ public function __construct( $this->y = $y; $this->x = $x; } - - public function getOperator(): string - { - return '$atan2'; - } } diff --git a/src/Builder/Expression/AtanOperator.php b/src/Builder/Expression/AtanOperator.php index 7ba685da0..6362570d6 100644 --- a/src/Builder/Expression/AtanOperator.php +++ b/src/Builder/Expression/AtanOperator.php @@ -22,6 +22,7 @@ final class AtanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$atan'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$atan'; - } } diff --git a/src/Builder/Expression/AtanhOperator.php b/src/Builder/Expression/AtanhOperator.php index ad2ab4df1..bdfba8ad9 100644 --- a/src/Builder/Expression/AtanhOperator.php +++ b/src/Builder/Expression/AtanhOperator.php @@ -22,6 +22,7 @@ final class AtanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$atanh'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$atanh'; - } } diff --git a/src/Builder/Expression/AvgOperator.php b/src/Builder/Expression/AvgOperator.php index ba6d83fa3..31745f14a 100644 --- a/src/Builder/Expression/AvgOperator.php +++ b/src/Builder/Expression/AvgOperator.php @@ -26,6 +26,7 @@ final class AvgOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$avg'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -47,9 +48,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$avg'; - } } diff --git a/src/Builder/Expression/BinarySizeOperator.php b/src/Builder/Expression/BinarySizeOperator.php index 0dfc99fdd..792da66b0 100644 --- a/src/Builder/Expression/BinarySizeOperator.php +++ b/src/Builder/Expression/BinarySizeOperator.php @@ -21,6 +21,7 @@ final class BinarySizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$binarySize'; public const PROPERTIES = ['expression' => 'expression']; /** @var Binary|ResolvesToBinData|ResolvesToNull|ResolvesToString|null|string $expression */ @@ -33,9 +34,4 @@ public function __construct(Binary|ResolvesToBinData|ResolvesToNull|ResolvesToSt { $this->expression = $expression; } - - public function getOperator(): string - { - return '$binarySize'; - } } diff --git a/src/Builder/Expression/BitAndOperator.php b/src/Builder/Expression/BitAndOperator.php index a66b516d7..bf0e3cd73 100644 --- a/src/Builder/Expression/BitAndOperator.php +++ b/src/Builder/Expression/BitAndOperator.php @@ -25,6 +25,7 @@ final class BitAndOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitAnd'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -46,9 +47,4 @@ public function __construct(Int64|ResolvesToInt|ResolvesToLong|int ...$expressio $this->expression = $expression; } - - public function getOperator(): string - { - return '$bitAnd'; - } } diff --git a/src/Builder/Expression/BitNotOperator.php b/src/Builder/Expression/BitNotOperator.php index 4acbf652c..6f388919f 100644 --- a/src/Builder/Expression/BitNotOperator.php +++ b/src/Builder/Expression/BitNotOperator.php @@ -22,6 +22,7 @@ final class BitNotOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitNot'; public const PROPERTIES = ['expression' => 'expression']; /** @var Int64|ResolvesToInt|ResolvesToLong|int $expression */ @@ -34,9 +35,4 @@ public function __construct(Int64|ResolvesToInt|ResolvesToLong|int $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$bitNot'; - } } diff --git a/src/Builder/Expression/BitOrOperator.php b/src/Builder/Expression/BitOrOperator.php index db435a710..b2490a4f6 100644 --- a/src/Builder/Expression/BitOrOperator.php +++ b/src/Builder/Expression/BitOrOperator.php @@ -25,6 +25,7 @@ final class BitOrOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitOr'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -46,9 +47,4 @@ public function __construct(Int64|ResolvesToInt|ResolvesToLong|int ...$expressio $this->expression = $expression; } - - public function getOperator(): string - { - return '$bitOr'; - } } diff --git a/src/Builder/Expression/BitXorOperator.php b/src/Builder/Expression/BitXorOperator.php index 6b86ea43f..0f0bc0e5a 100644 --- a/src/Builder/Expression/BitXorOperator.php +++ b/src/Builder/Expression/BitXorOperator.php @@ -25,6 +25,7 @@ final class BitXorOperator implements ResolvesToInt, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitXor'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -46,9 +47,4 @@ public function __construct(Int64|ResolvesToInt|ResolvesToLong|int ...$expressio $this->expression = $expression; } - - public function getOperator(): string - { - return '$bitXor'; - } } diff --git a/src/Builder/Expression/BsonSizeOperator.php b/src/Builder/Expression/BsonSizeOperator.php index cdf5e27c9..962d8c6db 100644 --- a/src/Builder/Expression/BsonSizeOperator.php +++ b/src/Builder/Expression/BsonSizeOperator.php @@ -23,6 +23,7 @@ final class BsonSizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bsonSize'; public const PROPERTIES = ['object' => 'object']; /** @var Document|ResolvesToNull|ResolvesToObject|Serializable|array|null|stdClass $object */ @@ -35,9 +36,4 @@ public function __construct(Document|Serializable|ResolvesToNull|ResolvesToObjec { $this->object = $object; } - - public function getOperator(): string - { - return '$bsonSize'; - } } diff --git a/src/Builder/Expression/CaseOperator.php b/src/Builder/Expression/CaseOperator.php index c43db4b7f..27da77d71 100644 --- a/src/Builder/Expression/CaseOperator.php +++ b/src/Builder/Expression/CaseOperator.php @@ -23,7 +23,8 @@ */ final class CaseOperator implements SwitchBranchInterface, OperatorInterface { - public const ENCODE = Encode::FlatObject; + public const ENCODE = Encode::Object; + public const NAME = null; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->case = $case; $this->then = $then; } - - public function getOperator(): string - { - return '$case'; - } } diff --git a/src/Builder/Expression/CeilOperator.php b/src/Builder/Expression/CeilOperator.php index e997a5fd8..c6771b81f 100644 --- a/src/Builder/Expression/CeilOperator.php +++ b/src/Builder/Expression/CeilOperator.php @@ -22,6 +22,7 @@ final class CeilOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$ceil'; 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. */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$ceil'; - } } diff --git a/src/Builder/Expression/CmpOperator.php b/src/Builder/Expression/CmpOperator.php index 620602680..72f27face 100644 --- a/src/Builder/Expression/CmpOperator.php +++ b/src/Builder/Expression/CmpOperator.php @@ -23,6 +23,7 @@ final class CmpOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$cmp'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$cmp'; - } } diff --git a/src/Builder/Expression/ConcatArraysOperator.php b/src/Builder/Expression/ConcatArraysOperator.php index 27ad5736c..17e736a78 100644 --- a/src/Builder/Expression/ConcatArraysOperator.php +++ b/src/Builder/Expression/ConcatArraysOperator.php @@ -25,6 +25,7 @@ final class ConcatArraysOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$concatArrays'; public const PROPERTIES = ['array' => 'array']; /** @var list $array */ @@ -46,9 +47,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array ...$arra $this->array = $array; } - - public function getOperator(): string - { - return '$concatArrays'; - } } diff --git a/src/Builder/Expression/ConcatOperator.php b/src/Builder/Expression/ConcatOperator.php index c1ac43294..c8497be08 100644 --- a/src/Builder/Expression/ConcatOperator.php +++ b/src/Builder/Expression/ConcatOperator.php @@ -23,6 +23,7 @@ final class ConcatOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$concat'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -44,9 +45,4 @@ public function __construct(ResolvesToString|string ...$expression) $this->expression = $expression; } - - public function getOperator(): string - { - return '$concat'; - } } diff --git a/src/Builder/Expression/CondOperator.php b/src/Builder/Expression/CondOperator.php index 97b286e45..26ca336f5 100644 --- a/src/Builder/Expression/CondOperator.php +++ b/src/Builder/Expression/CondOperator.php @@ -23,6 +23,7 @@ final class CondOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$cond'; public const PROPERTIES = ['if' => 'if', 'then' => 'then', 'else' => 'else']; /** @var ResolvesToBool|bool $if */ @@ -48,9 +49,4 @@ public function __construct( $this->then = $then; $this->else = $else; } - - public function getOperator(): string - { - return '$cond'; - } } diff --git a/src/Builder/Expression/ConvertOperator.php b/src/Builder/Expression/ConvertOperator.php index 0418c26b9..92bfecb02 100644 --- a/src/Builder/Expression/ConvertOperator.php +++ b/src/Builder/Expression/ConvertOperator.php @@ -25,6 +25,7 @@ final class ConvertOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$convert'; public const PROPERTIES = ['input' => 'input', 'to' => 'to', 'onError' => 'onError', 'onNull' => 'onNull']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $input */ @@ -64,9 +65,4 @@ public function __construct( $this->onError = $onError; $this->onNull = $onNull; } - - public function getOperator(): string - { - return '$convert'; - } } diff --git a/src/Builder/Expression/CosOperator.php b/src/Builder/Expression/CosOperator.php index 0b5a2e7e7..e06afa635 100644 --- a/src/Builder/Expression/CosOperator.php +++ b/src/Builder/Expression/CosOperator.php @@ -22,6 +22,7 @@ final class CosOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$cos'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$cos'; - } } diff --git a/src/Builder/Expression/CoshOperator.php b/src/Builder/Expression/CoshOperator.php index b1a481772..c44dccb0b 100644 --- a/src/Builder/Expression/CoshOperator.php +++ b/src/Builder/Expression/CoshOperator.php @@ -22,6 +22,7 @@ final class CoshOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$cosh'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$cosh'; - } } diff --git a/src/Builder/Expression/DateAddOperator.php b/src/Builder/Expression/DateAddOperator.php index 208a1e4dc..0c0bbf100 100644 --- a/src/Builder/Expression/DateAddOperator.php +++ b/src/Builder/Expression/DateAddOperator.php @@ -26,6 +26,7 @@ final class DateAddOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateAdd'; 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. */ @@ -57,9 +58,4 @@ public function __construct( $this->amount = $amount; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$dateAdd'; - } } diff --git a/src/Builder/Expression/DateDiffOperator.php b/src/Builder/Expression/DateDiffOperator.php index 67b2bfc2f..a12ea935c 100644 --- a/src/Builder/Expression/DateDiffOperator.php +++ b/src/Builder/Expression/DateDiffOperator.php @@ -25,6 +25,7 @@ final class DateDiffOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateDiff'; public const PROPERTIES = [ 'startDate' => 'startDate', @@ -69,9 +70,4 @@ public function __construct( $this->timezone = $timezone; $this->startOfWeek = $startOfWeek; } - - public function getOperator(): string - { - return '$dateDiff'; - } } diff --git a/src/Builder/Expression/DateFromPartsOperator.php b/src/Builder/Expression/DateFromPartsOperator.php index 1cd5cd678..877bfdd65 100644 --- a/src/Builder/Expression/DateFromPartsOperator.php +++ b/src/Builder/Expression/DateFromPartsOperator.php @@ -23,6 +23,7 @@ final class DateFromPartsOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateFromParts'; public const PROPERTIES = [ 'year' => 'year', @@ -109,9 +110,4 @@ public function __construct( $this->millisecond = $millisecond; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$dateFromParts'; - } } diff --git a/src/Builder/Expression/DateFromStringOperator.php b/src/Builder/Expression/DateFromStringOperator.php index 0d35eb7b3..60c20fed1 100644 --- a/src/Builder/Expression/DateFromStringOperator.php +++ b/src/Builder/Expression/DateFromStringOperator.php @@ -24,6 +24,7 @@ final class DateFromStringOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateFromString'; public const PROPERTIES = [ 'dateString' => 'dateString', @@ -80,9 +81,4 @@ public function __construct( $this->onError = $onError; $this->onNull = $onNull; } - - public function getOperator(): string - { - return '$dateFromString'; - } } diff --git a/src/Builder/Expression/DateSubtractOperator.php b/src/Builder/Expression/DateSubtractOperator.php index 4112ded11..11fbfdcfd 100644 --- a/src/Builder/Expression/DateSubtractOperator.php +++ b/src/Builder/Expression/DateSubtractOperator.php @@ -26,6 +26,7 @@ final class DateSubtractOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateSubtract'; 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. */ @@ -57,9 +58,4 @@ public function __construct( $this->amount = $amount; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$dateSubtract'; - } } diff --git a/src/Builder/Expression/DateToPartsOperator.php b/src/Builder/Expression/DateToPartsOperator.php index 1d8754a4d..3573e59c8 100644 --- a/src/Builder/Expression/DateToPartsOperator.php +++ b/src/Builder/Expression/DateToPartsOperator.php @@ -24,6 +24,7 @@ final class DateToPartsOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateToParts'; 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. */ @@ -49,9 +50,4 @@ public function __construct( $this->timezone = $timezone; $this->iso8601 = $iso8601; } - - public function getOperator(): string - { - return '$dateToParts'; - } } diff --git a/src/Builder/Expression/DateToStringOperator.php b/src/Builder/Expression/DateToStringOperator.php index d1403f67c..7f9ede2d9 100644 --- a/src/Builder/Expression/DateToStringOperator.php +++ b/src/Builder/Expression/DateToStringOperator.php @@ -27,6 +27,7 @@ final class DateToStringOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateToString'; 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. */ @@ -66,9 +67,4 @@ public function __construct( $this->timezone = $timezone; $this->onNull = $onNull; } - - public function getOperator(): string - { - return '$dateToString'; - } } diff --git a/src/Builder/Expression/DateTruncOperator.php b/src/Builder/Expression/DateTruncOperator.php index 643cd3a7f..b5e162bba 100644 --- a/src/Builder/Expression/DateTruncOperator.php +++ b/src/Builder/Expression/DateTruncOperator.php @@ -27,6 +27,7 @@ final class DateTruncOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dateTrunc'; public const PROPERTIES = [ 'date' => 'date', @@ -83,9 +84,4 @@ public function __construct( $this->timezone = $timezone; $this->startOfWeek = $startOfWeek; } - - public function getOperator(): string - { - return '$dateTrunc'; - } } diff --git a/src/Builder/Expression/DayOfMonthOperator.php b/src/Builder/Expression/DayOfMonthOperator.php index 1d336d692..bc0ccb28f 100644 --- a/src/Builder/Expression/DayOfMonthOperator.php +++ b/src/Builder/Expression/DayOfMonthOperator.php @@ -24,6 +24,7 @@ final class DayOfMonthOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dayOfMonth'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$dayOfMonth'; - } } diff --git a/src/Builder/Expression/DayOfWeekOperator.php b/src/Builder/Expression/DayOfWeekOperator.php index 51e296d73..e9dbbfa08 100644 --- a/src/Builder/Expression/DayOfWeekOperator.php +++ b/src/Builder/Expression/DayOfWeekOperator.php @@ -24,6 +24,7 @@ final class DayOfWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dayOfWeek'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$dayOfWeek'; - } } diff --git a/src/Builder/Expression/DayOfYearOperator.php b/src/Builder/Expression/DayOfYearOperator.php index febb353a5..86c20ab20 100644 --- a/src/Builder/Expression/DayOfYearOperator.php +++ b/src/Builder/Expression/DayOfYearOperator.php @@ -24,6 +24,7 @@ final class DayOfYearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$dayOfYear'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$dayOfYear'; - } } diff --git a/src/Builder/Expression/DegreesToRadiansOperator.php b/src/Builder/Expression/DegreesToRadiansOperator.php index 412a49791..b8d2bb07a 100644 --- a/src/Builder/Expression/DegreesToRadiansOperator.php +++ b/src/Builder/Expression/DegreesToRadiansOperator.php @@ -22,6 +22,7 @@ final class DegreesToRadiansOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$degreesToRadians'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$degreesToRadians'; - } } diff --git a/src/Builder/Expression/DivideOperator.php b/src/Builder/Expression/DivideOperator.php index 79962ca25..74de49c20 100644 --- a/src/Builder/Expression/DivideOperator.php +++ b/src/Builder/Expression/DivideOperator.php @@ -22,6 +22,7 @@ final class DivideOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$divide'; 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. */ @@ -41,9 +42,4 @@ public function __construct( $this->dividend = $dividend; $this->divisor = $divisor; } - - public function getOperator(): string - { - return '$divide'; - } } diff --git a/src/Builder/Expression/EqOperator.php b/src/Builder/Expression/EqOperator.php index 7717ad6d3..f78d0ff3b 100644 --- a/src/Builder/Expression/EqOperator.php +++ b/src/Builder/Expression/EqOperator.php @@ -23,6 +23,7 @@ final class EqOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$eq'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$eq'; - } } diff --git a/src/Builder/Expression/ExpOperator.php b/src/Builder/Expression/ExpOperator.php index ad37f8365..78037fb9e 100644 --- a/src/Builder/Expression/ExpOperator.php +++ b/src/Builder/Expression/ExpOperator.php @@ -22,6 +22,7 @@ final class ExpOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$exp'; public const PROPERTIES = ['exponent' => 'exponent']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $exponent */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $exponen { $this->exponent = $exponent; } - - public function getOperator(): string - { - return '$exp'; - } } diff --git a/src/Builder/Expression/FilterOperator.php b/src/Builder/Expression/FilterOperator.php index 665e196e7..9bd522572 100644 --- a/src/Builder/Expression/FilterOperator.php +++ b/src/Builder/Expression/FilterOperator.php @@ -27,6 +27,7 @@ final class FilterOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$filter'; public const PROPERTIES = ['input' => 'input', 'cond' => 'cond', 'as' => 'as', 'limit' => 'limit']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input */ @@ -66,9 +67,4 @@ public function __construct( $this->as = $as; $this->limit = $limit; } - - public function getOperator(): string - { - return '$filter'; - } } diff --git a/src/Builder/Expression/FirstNOperator.php b/src/Builder/Expression/FirstNOperator.php index c8276f33c..769c38118 100644 --- a/src/Builder/Expression/FirstNOperator.php +++ b/src/Builder/Expression/FirstNOperator.php @@ -26,6 +26,7 @@ final class FirstNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$firstN'; 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. */ @@ -47,9 +48,4 @@ public function __construct(ResolvesToInt|int $n, PackedArray|ResolvesToArray|BS $this->input = $input; } - - public function getOperator(): string - { - return '$firstN'; - } } diff --git a/src/Builder/Expression/FirstOperator.php b/src/Builder/Expression/FirstOperator.php index 318dc4769..994de7bee 100644 --- a/src/Builder/Expression/FirstOperator.php +++ b/src/Builder/Expression/FirstOperator.php @@ -26,6 +26,7 @@ final class FirstOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$first'; public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $express $this->expression = $expression; } - - public function getOperator(): string - { - return '$first'; - } } diff --git a/src/Builder/Expression/FloorOperator.php b/src/Builder/Expression/FloorOperator.php index ec974417c..741412330 100644 --- a/src/Builder/Expression/FloorOperator.php +++ b/src/Builder/Expression/FloorOperator.php @@ -22,6 +22,7 @@ final class FloorOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$floor'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$floor'; - } } diff --git a/src/Builder/Expression/FunctionOperator.php b/src/Builder/Expression/FunctionOperator.php index 6b9d1ba8a..516729e3a 100644 --- a/src/Builder/Expression/FunctionOperator.php +++ b/src/Builder/Expression/FunctionOperator.php @@ -29,6 +29,7 @@ final class FunctionOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$function'; public const PROPERTIES = ['body' => 'body', 'args' => 'args', 'lang' => 'lang']; /** @@ -63,9 +64,4 @@ public function __construct(Javascript|string $body, PackedArray|BSONArray|array $this->args = $args; $this->lang = $lang; } - - public function getOperator(): string - { - return '$function'; - } } diff --git a/src/Builder/Expression/GetFieldOperator.php b/src/Builder/Expression/GetFieldOperator.php index 188c074fe..622bacb85 100644 --- a/src/Builder/Expression/GetFieldOperator.php +++ b/src/Builder/Expression/GetFieldOperator.php @@ -25,6 +25,7 @@ final class GetFieldOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$getField'; public const PROPERTIES = ['field' => 'field', 'input' => 'input']; /** @@ -52,9 +53,4 @@ public function __construct( $this->field = $field; $this->input = $input; } - - public function getOperator(): string - { - return '$getField'; - } } diff --git a/src/Builder/Expression/GtOperator.php b/src/Builder/Expression/GtOperator.php index badb0b951..fda780fff 100644 --- a/src/Builder/Expression/GtOperator.php +++ b/src/Builder/Expression/GtOperator.php @@ -23,6 +23,7 @@ final class GtOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$gt'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$gt'; - } } diff --git a/src/Builder/Expression/GteOperator.php b/src/Builder/Expression/GteOperator.php index 45931a7ae..8f5792770 100644 --- a/src/Builder/Expression/GteOperator.php +++ b/src/Builder/Expression/GteOperator.php @@ -23,6 +23,7 @@ final class GteOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$gte'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$gte'; - } } diff --git a/src/Builder/Expression/HourOperator.php b/src/Builder/Expression/HourOperator.php index 47d7ba339..5c68b7446 100644 --- a/src/Builder/Expression/HourOperator.php +++ b/src/Builder/Expression/HourOperator.php @@ -24,6 +24,7 @@ final class HourOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$hour'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$hour'; - } } diff --git a/src/Builder/Expression/IfNullOperator.php b/src/Builder/Expression/IfNullOperator.php index 06a7926a4..51c393d28 100644 --- a/src/Builder/Expression/IfNullOperator.php +++ b/src/Builder/Expression/IfNullOperator.php @@ -26,6 +26,7 @@ final class IfNullOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$ifNull'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -47,9 +48,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i $this->expression = $expression; } - - public function getOperator(): string - { - return '$ifNull'; - } } diff --git a/src/Builder/Expression/InOperator.php b/src/Builder/Expression/InOperator.php index 31d78bb26..c2e24b9dc 100644 --- a/src/Builder/Expression/InOperator.php +++ b/src/Builder/Expression/InOperator.php @@ -29,6 +29,7 @@ final class InOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$in'; public const PROPERTIES = ['expression' => 'expression', 'array' => 'array']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression Any valid expression expression. */ @@ -52,9 +53,4 @@ public function __construct( $this->array = $array; } - - public function getOperator(): string - { - return '$in'; - } } diff --git a/src/Builder/Expression/IndexOfArrayOperator.php b/src/Builder/Expression/IndexOfArrayOperator.php index 912e20a86..15e3e4626 100644 --- a/src/Builder/Expression/IndexOfArrayOperator.php +++ b/src/Builder/Expression/IndexOfArrayOperator.php @@ -30,6 +30,7 @@ final class IndexOfArrayOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$indexOfArray'; public const PROPERTIES = ['array' => 'array', 'search' => 'search', 'start' => 'start', 'end' => 'end']; /** @@ -79,9 +80,4 @@ public function __construct( $this->start = $start; $this->end = $end; } - - public function getOperator(): string - { - return '$indexOfArray'; - } } diff --git a/src/Builder/Expression/IndexOfBytesOperator.php b/src/Builder/Expression/IndexOfBytesOperator.php index 788b4ecb9..9f3d07533 100644 --- a/src/Builder/Expression/IndexOfBytesOperator.php +++ b/src/Builder/Expression/IndexOfBytesOperator.php @@ -21,6 +21,7 @@ final class IndexOfBytesOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$indexOfBytes'; public const PROPERTIES = ['string' => 'string', 'substring' => 'substring', 'start' => 'start', 'end' => 'end']; /** @@ -66,9 +67,4 @@ public function __construct( $this->start = $start; $this->end = $end; } - - public function getOperator(): string - { - return '$indexOfBytes'; - } } diff --git a/src/Builder/Expression/IndexOfCPOperator.php b/src/Builder/Expression/IndexOfCPOperator.php index 076b7747c..735de9759 100644 --- a/src/Builder/Expression/IndexOfCPOperator.php +++ b/src/Builder/Expression/IndexOfCPOperator.php @@ -21,6 +21,7 @@ final class IndexOfCPOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$indexOfCP'; public const PROPERTIES = ['string' => 'string', 'substring' => 'substring', 'start' => 'start', 'end' => 'end']; /** @@ -66,9 +67,4 @@ public function __construct( $this->start = $start; $this->end = $end; } - - public function getOperator(): string - { - return '$indexOfCP'; - } } diff --git a/src/Builder/Expression/IsArrayOperator.php b/src/Builder/Expression/IsArrayOperator.php index 7a8329acb..abd075103 100644 --- a/src/Builder/Expression/IsArrayOperator.php +++ b/src/Builder/Expression/IsArrayOperator.php @@ -23,6 +23,7 @@ final class IsArrayOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$isArray'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -35,9 +36,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$isArray'; - } } diff --git a/src/Builder/Expression/IsNumberOperator.php b/src/Builder/Expression/IsNumberOperator.php index 65a94800b..a76530242 100644 --- a/src/Builder/Expression/IsNumberOperator.php +++ b/src/Builder/Expression/IsNumberOperator.php @@ -25,6 +25,7 @@ final class IsNumberOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$isNumber'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -37,9 +38,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$isNumber'; - } } diff --git a/src/Builder/Expression/IsoDayOfWeekOperator.php b/src/Builder/Expression/IsoDayOfWeekOperator.php index 68eb77cc2..8bbc8dfe9 100644 --- a/src/Builder/Expression/IsoDayOfWeekOperator.php +++ b/src/Builder/Expression/IsoDayOfWeekOperator.php @@ -24,6 +24,7 @@ final class IsoDayOfWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$isoDayOfWeek'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$isoDayOfWeek'; - } } diff --git a/src/Builder/Expression/IsoWeekOperator.php b/src/Builder/Expression/IsoWeekOperator.php index b86fa89cf..726c53537 100644 --- a/src/Builder/Expression/IsoWeekOperator.php +++ b/src/Builder/Expression/IsoWeekOperator.php @@ -24,6 +24,7 @@ final class IsoWeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$isoWeek'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$isoWeek'; - } } diff --git a/src/Builder/Expression/IsoWeekYearOperator.php b/src/Builder/Expression/IsoWeekYearOperator.php index a9df2dc4f..a29e2e8a6 100644 --- a/src/Builder/Expression/IsoWeekYearOperator.php +++ b/src/Builder/Expression/IsoWeekYearOperator.php @@ -24,6 +24,7 @@ final class IsoWeekYearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$isoWeekYear'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$isoWeekYear'; - } } diff --git a/src/Builder/Expression/LastNOperator.php b/src/Builder/Expression/LastNOperator.php index fe6c65110..0517f92d8 100644 --- a/src/Builder/Expression/LastNOperator.php +++ b/src/Builder/Expression/LastNOperator.php @@ -26,6 +26,7 @@ final class LastNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$lastN'; 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. */ @@ -47,9 +48,4 @@ public function __construct(ResolvesToInt|int $n, PackedArray|ResolvesToArray|BS $this->input = $input; } - - public function getOperator(): string - { - return '$lastN'; - } } diff --git a/src/Builder/Expression/LastOperator.php b/src/Builder/Expression/LastOperator.php index 28b913c3b..e7f2b7d46 100644 --- a/src/Builder/Expression/LastOperator.php +++ b/src/Builder/Expression/LastOperator.php @@ -26,6 +26,7 @@ final class LastOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$last'; public const PROPERTIES = ['expression' => 'expression']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $express $this->expression = $expression; } - - public function getOperator(): string - { - return '$last'; - } } diff --git a/src/Builder/Expression/LetOperator.php b/src/Builder/Expression/LetOperator.php index 41d9428ff..3f0fde195 100644 --- a/src/Builder/Expression/LetOperator.php +++ b/src/Builder/Expression/LetOperator.php @@ -26,6 +26,7 @@ final class LetOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$let'; public const PROPERTIES = ['vars' => 'vars', 'in' => 'in']; /** @@ -49,9 +50,4 @@ public function __construct( $this->vars = $vars; $this->in = $in; } - - public function getOperator(): string - { - return '$let'; - } } diff --git a/src/Builder/Expression/LiteralOperator.php b/src/Builder/Expression/LiteralOperator.php index be1d2e0d4..fc80506e4 100644 --- a/src/Builder/Expression/LiteralOperator.php +++ b/src/Builder/Expression/LiteralOperator.php @@ -22,6 +22,7 @@ final class LiteralOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$literal'; 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. */ @@ -34,9 +35,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$literal'; - } } diff --git a/src/Builder/Expression/LnOperator.php b/src/Builder/Expression/LnOperator.php index a62a522b8..6fe5993e9 100644 --- a/src/Builder/Expression/LnOperator.php +++ b/src/Builder/Expression/LnOperator.php @@ -23,6 +23,7 @@ final class LnOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$ln'; 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. */ @@ -35,9 +36,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $number) { $this->number = $number; } - - public function getOperator(): string - { - return '$ln'; - } } diff --git a/src/Builder/Expression/Log10Operator.php b/src/Builder/Expression/Log10Operator.php index ed097e9a6..ef4a5ec3e 100644 --- a/src/Builder/Expression/Log10Operator.php +++ b/src/Builder/Expression/Log10Operator.php @@ -22,6 +22,7 @@ final class Log10Operator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$log10'; 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. */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $number) { $this->number = $number; } - - public function getOperator(): string - { - return '$log10'; - } } diff --git a/src/Builder/Expression/LogOperator.php b/src/Builder/Expression/LogOperator.php index 8bd2067f9..99bbfd812 100644 --- a/src/Builder/Expression/LogOperator.php +++ b/src/Builder/Expression/LogOperator.php @@ -22,6 +22,7 @@ final class LogOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$log'; 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. */ @@ -41,9 +42,4 @@ public function __construct( $this->number = $number; $this->base = $base; } - - public function getOperator(): string - { - return '$log'; - } } diff --git a/src/Builder/Expression/LtOperator.php b/src/Builder/Expression/LtOperator.php index 0dab045fc..7ea54defa 100644 --- a/src/Builder/Expression/LtOperator.php +++ b/src/Builder/Expression/LtOperator.php @@ -23,6 +23,7 @@ final class LtOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$lt'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$lt'; - } } diff --git a/src/Builder/Expression/LteOperator.php b/src/Builder/Expression/LteOperator.php index 2358b2cab..caeec2165 100644 --- a/src/Builder/Expression/LteOperator.php +++ b/src/Builder/Expression/LteOperator.php @@ -23,6 +23,7 @@ final class LteOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$lte'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$lte'; - } } diff --git a/src/Builder/Expression/LtrimOperator.php b/src/Builder/Expression/LtrimOperator.php index 6327a5529..0dd94eaab 100644 --- a/src/Builder/Expression/LtrimOperator.php +++ b/src/Builder/Expression/LtrimOperator.php @@ -22,6 +22,7 @@ final class LtrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$ltrim'; 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. */ @@ -47,9 +48,4 @@ public function __construct( $this->input = $input; $this->chars = $chars; } - - public function getOperator(): string - { - return '$ltrim'; - } } diff --git a/src/Builder/Expression/MapOperator.php b/src/Builder/Expression/MapOperator.php index 1fd98300b..a63685a88 100644 --- a/src/Builder/Expression/MapOperator.php +++ b/src/Builder/Expression/MapOperator.php @@ -30,6 +30,7 @@ final class MapOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$map'; public const PROPERTIES = ['input' => 'input', 'in' => 'in', 'as' => 'as']; /** @var BSONArray|PackedArray|ResolvesToArray|array $input An expression that resolves to an array. */ @@ -59,9 +60,4 @@ public function __construct( $this->in = $in; $this->as = $as; } - - public function getOperator(): string - { - return '$map'; - } } diff --git a/src/Builder/Expression/MaxNOperator.php b/src/Builder/Expression/MaxNOperator.php index 11dd0ba66..f8d387257 100644 --- a/src/Builder/Expression/MaxNOperator.php +++ b/src/Builder/Expression/MaxNOperator.php @@ -26,6 +26,7 @@ final class MaxNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$maxN'; 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. */ @@ -47,9 +48,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $input, $this->input = $input; $this->n = $n; } - - public function getOperator(): string - { - return '$maxN'; - } } diff --git a/src/Builder/Expression/MaxOperator.php b/src/Builder/Expression/MaxOperator.php index fee83dcdc..5c1923377 100644 --- a/src/Builder/Expression/MaxOperator.php +++ b/src/Builder/Expression/MaxOperator.php @@ -27,6 +27,7 @@ final class MaxOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$max'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -48,9 +49,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i $this->expression = $expression; } - - public function getOperator(): string - { - return '$max'; - } } diff --git a/src/Builder/Expression/MedianOperator.php b/src/Builder/Expression/MedianOperator.php index 3591950bf..bae54c838 100644 --- a/src/Builder/Expression/MedianOperator.php +++ b/src/Builder/Expression/MedianOperator.php @@ -33,6 +33,7 @@ final class MedianOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$median'; 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. */ @@ -56,9 +57,4 @@ public function __construct( $this->input = $input; $this->method = $method; } - - public function getOperator(): string - { - return '$median'; - } } diff --git a/src/Builder/Expression/MergeObjectsOperator.php b/src/Builder/Expression/MergeObjectsOperator.php index b5f001971..45e73a59e 100644 --- a/src/Builder/Expression/MergeObjectsOperator.php +++ b/src/Builder/Expression/MergeObjectsOperator.php @@ -26,6 +26,7 @@ final class MergeObjectsOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$mergeObjects'; public const PROPERTIES = ['document' => 'document']; /** @var list $document Any valid expression that resolves to a document. */ @@ -47,9 +48,4 @@ public function __construct(Document|Serializable|ResolvesToObject|stdClass|arra $this->document = $document; } - - public function getOperator(): string - { - return '$mergeObjects'; - } } diff --git a/src/Builder/Expression/MetaOperator.php b/src/Builder/Expression/MetaOperator.php index f42068b8a..ec1fd63e6 100644 --- a/src/Builder/Expression/MetaOperator.php +++ b/src/Builder/Expression/MetaOperator.php @@ -20,6 +20,7 @@ final class MetaOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$meta'; public const PROPERTIES = ['keyword' => 'keyword']; /** @var string $keyword */ @@ -32,9 +33,4 @@ public function __construct(string $keyword) { $this->keyword = $keyword; } - - public function getOperator(): string - { - return '$meta'; - } } diff --git a/src/Builder/Expression/MillisecondOperator.php b/src/Builder/Expression/MillisecondOperator.php index 3d229a3d8..06d8a4bd8 100644 --- a/src/Builder/Expression/MillisecondOperator.php +++ b/src/Builder/Expression/MillisecondOperator.php @@ -24,6 +24,7 @@ final class MillisecondOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$millisecond'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$millisecond'; - } } diff --git a/src/Builder/Expression/MinNOperator.php b/src/Builder/Expression/MinNOperator.php index a6bff71ef..9d032fe3e 100644 --- a/src/Builder/Expression/MinNOperator.php +++ b/src/Builder/Expression/MinNOperator.php @@ -26,6 +26,7 @@ final class MinNOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$minN'; 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. */ @@ -47,9 +48,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $input, $this->input = $input; $this->n = $n; } - - public function getOperator(): string - { - return '$minN'; - } } diff --git a/src/Builder/Expression/MinOperator.php b/src/Builder/Expression/MinOperator.php index 95b609128..31f30e807 100644 --- a/src/Builder/Expression/MinOperator.php +++ b/src/Builder/Expression/MinOperator.php @@ -27,6 +27,7 @@ final class MinOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$min'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -48,9 +49,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i $this->expression = $expression; } - - public function getOperator(): string - { - return '$min'; - } } diff --git a/src/Builder/Expression/MinuteOperator.php b/src/Builder/Expression/MinuteOperator.php index d8eed1272..2be3b337d 100644 --- a/src/Builder/Expression/MinuteOperator.php +++ b/src/Builder/Expression/MinuteOperator.php @@ -24,6 +24,7 @@ final class MinuteOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$minute'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$minute'; - } } diff --git a/src/Builder/Expression/ModOperator.php b/src/Builder/Expression/ModOperator.php index 477828530..8a2134fac 100644 --- a/src/Builder/Expression/ModOperator.php +++ b/src/Builder/Expression/ModOperator.php @@ -22,6 +22,7 @@ final class ModOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$mod'; 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. */ @@ -41,9 +42,4 @@ public function __construct( $this->dividend = $dividend; $this->divisor = $divisor; } - - public function getOperator(): string - { - return '$mod'; - } } diff --git a/src/Builder/Expression/MonthOperator.php b/src/Builder/Expression/MonthOperator.php index e11d65ebc..36d1c2b17 100644 --- a/src/Builder/Expression/MonthOperator.php +++ b/src/Builder/Expression/MonthOperator.php @@ -24,6 +24,7 @@ final class MonthOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$month'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$month'; - } } diff --git a/src/Builder/Expression/MultiplyOperator.php b/src/Builder/Expression/MultiplyOperator.php index 609c5bb76..ba2f5882e 100644 --- a/src/Builder/Expression/MultiplyOperator.php +++ b/src/Builder/Expression/MultiplyOperator.php @@ -25,6 +25,7 @@ final class MultiplyOperator implements ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$multiply'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -50,9 +51,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$multiply'; - } } diff --git a/src/Builder/Expression/NeOperator.php b/src/Builder/Expression/NeOperator.php index ed8a4e423..1688d7406 100644 --- a/src/Builder/Expression/NeOperator.php +++ b/src/Builder/Expression/NeOperator.php @@ -23,6 +23,7 @@ final class NeOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$ne'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$ne'; - } } diff --git a/src/Builder/Expression/NotOperator.php b/src/Builder/Expression/NotOperator.php index 2b3b0c024..983fabc80 100644 --- a/src/Builder/Expression/NotOperator.php +++ b/src/Builder/Expression/NotOperator.php @@ -23,6 +23,7 @@ final class NotOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$not'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|ResolvesToBool|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct( ) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$not'; - } } diff --git a/src/Builder/Expression/ObjectToArrayOperator.php b/src/Builder/Expression/ObjectToArrayOperator.php index 6ca01f39b..0685bed27 100644 --- a/src/Builder/Expression/ObjectToArrayOperator.php +++ b/src/Builder/Expression/ObjectToArrayOperator.php @@ -23,6 +23,7 @@ final class ObjectToArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$objectToArray'; 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. */ @@ -35,9 +36,4 @@ public function __construct(Document|Serializable|ResolvesToObject|stdClass|arra { $this->object = $object; } - - public function getOperator(): string - { - return '$objectToArray'; - } } diff --git a/src/Builder/Expression/OrOperator.php b/src/Builder/Expression/OrOperator.php index 85447a484..758e73a70 100644 --- a/src/Builder/Expression/OrOperator.php +++ b/src/Builder/Expression/OrOperator.php @@ -26,6 +26,7 @@ final class OrOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$or'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -48,9 +49,4 @@ public function __construct( $this->expression = $expression; } - - public function getOperator(): string - { - return '$or'; - } } diff --git a/src/Builder/Expression/PercentileOperator.php b/src/Builder/Expression/PercentileOperator.php index fad9e64e5..ab956bac5 100644 --- a/src/Builder/Expression/PercentileOperator.php +++ b/src/Builder/Expression/PercentileOperator.php @@ -36,6 +36,7 @@ final class PercentileOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$percentile'; 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. */ @@ -73,9 +74,4 @@ public function __construct( $this->p = $p; $this->method = $method; } - - public function getOperator(): string - { - return '$percentile'; - } } diff --git a/src/Builder/Expression/PowOperator.php b/src/Builder/Expression/PowOperator.php index cc6ecdd4f..8cf024023 100644 --- a/src/Builder/Expression/PowOperator.php +++ b/src/Builder/Expression/PowOperator.php @@ -22,6 +22,7 @@ final class PowOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$pow'; public const PROPERTIES = ['number' => 'number', 'exponent' => 'exponent']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $number */ @@ -41,9 +42,4 @@ public function __construct( $this->number = $number; $this->exponent = $exponent; } - - public function getOperator(): string - { - return '$pow'; - } } diff --git a/src/Builder/Expression/RadiansToDegreesOperator.php b/src/Builder/Expression/RadiansToDegreesOperator.php index 60717f251..b3764f0ed 100644 --- a/src/Builder/Expression/RadiansToDegreesOperator.php +++ b/src/Builder/Expression/RadiansToDegreesOperator.php @@ -22,6 +22,7 @@ final class RadiansToDegreesOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$radiansToDegrees'; public const PROPERTIES = ['expression' => 'expression']; /** @var Decimal128|Int64|ResolvesToNumber|float|int $expression */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$radiansToDegrees'; - } } diff --git a/src/Builder/Expression/RandOperator.php b/src/Builder/Expression/RandOperator.php index 02c41c805..26da27637 100644 --- a/src/Builder/Expression/RandOperator.php +++ b/src/Builder/Expression/RandOperator.php @@ -20,13 +20,9 @@ final class RandOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$rand'; public function __construct() { } - - public function getOperator(): string - { - return '$rand'; - } } diff --git a/src/Builder/Expression/RangeOperator.php b/src/Builder/Expression/RangeOperator.php index 86f638554..cbb0e32e7 100644 --- a/src/Builder/Expression/RangeOperator.php +++ b/src/Builder/Expression/RangeOperator.php @@ -21,6 +21,7 @@ final class RangeOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$range'; 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. */ @@ -46,9 +47,4 @@ public function __construct( $this->end = $end; $this->step = $step; } - - public function getOperator(): string - { - return '$range'; - } } diff --git a/src/Builder/Expression/ReduceOperator.php b/src/Builder/Expression/ReduceOperator.php index 2652e5501..c35b2b530 100644 --- a/src/Builder/Expression/ReduceOperator.php +++ b/src/Builder/Expression/ReduceOperator.php @@ -29,6 +29,7 @@ final class ReduceOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$reduce'; public const PROPERTIES = ['input' => 'input', 'initialValue' => 'initialValue', 'in' => 'in']; /** @@ -72,9 +73,4 @@ public function __construct( $this->initialValue = $initialValue; $this->in = $in; } - - public function getOperator(): string - { - return '$reduce'; - } } diff --git a/src/Builder/Expression/RegexFindAllOperator.php b/src/Builder/Expression/RegexFindAllOperator.php index 20cdc69ae..e6e36a9fb 100644 --- a/src/Builder/Expression/RegexFindAllOperator.php +++ b/src/Builder/Expression/RegexFindAllOperator.php @@ -23,6 +23,7 @@ final class RegexFindAllOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$regexFindAll'; 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. */ @@ -48,9 +49,4 @@ public function __construct( $this->regex = $regex; $this->options = $options; } - - public function getOperator(): string - { - return '$regexFindAll'; - } } diff --git a/src/Builder/Expression/RegexFindOperator.php b/src/Builder/Expression/RegexFindOperator.php index ff6baa3d1..81f713f35 100644 --- a/src/Builder/Expression/RegexFindOperator.php +++ b/src/Builder/Expression/RegexFindOperator.php @@ -23,6 +23,7 @@ final class RegexFindOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$regexFind'; 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. */ @@ -48,9 +49,4 @@ public function __construct( $this->regex = $regex; $this->options = $options; } - - public function getOperator(): string - { - return '$regexFind'; - } } diff --git a/src/Builder/Expression/RegexMatchOperator.php b/src/Builder/Expression/RegexMatchOperator.php index 71c246fcc..50fbb1766 100644 --- a/src/Builder/Expression/RegexMatchOperator.php +++ b/src/Builder/Expression/RegexMatchOperator.php @@ -23,6 +23,7 @@ final class RegexMatchOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$regexMatch'; 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. */ @@ -48,9 +49,4 @@ public function __construct( $this->regex = $regex; $this->options = $options; } - - public function getOperator(): string - { - return '$regexMatch'; - } } diff --git a/src/Builder/Expression/ReplaceAllOperator.php b/src/Builder/Expression/ReplaceAllOperator.php index 29a57e282..14cfb17ea 100644 --- a/src/Builder/Expression/ReplaceAllOperator.php +++ b/src/Builder/Expression/ReplaceAllOperator.php @@ -22,6 +22,7 @@ final class ReplaceAllOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$replaceAll'; 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. */ @@ -47,9 +48,4 @@ public function __construct( $this->find = $find; $this->replacement = $replacement; } - - public function getOperator(): string - { - return '$replaceAll'; - } } diff --git a/src/Builder/Expression/ReplaceOneOperator.php b/src/Builder/Expression/ReplaceOneOperator.php index c16ae80bd..0237aacc0 100644 --- a/src/Builder/Expression/ReplaceOneOperator.php +++ b/src/Builder/Expression/ReplaceOneOperator.php @@ -21,6 +21,7 @@ final class ReplaceOneOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$replaceOne'; 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. */ @@ -46,9 +47,4 @@ public function __construct( $this->find = $find; $this->replacement = $replacement; } - - public function getOperator(): string - { - return '$replaceOne'; - } } diff --git a/src/Builder/Expression/ReverseArrayOperator.php b/src/Builder/Expression/ReverseArrayOperator.php index 01a22410d..be6a910d4 100644 --- a/src/Builder/Expression/ReverseArrayOperator.php +++ b/src/Builder/Expression/ReverseArrayOperator.php @@ -26,6 +26,7 @@ final class ReverseArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$reverseArray'; 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. */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $express $this->expression = $expression; } - - public function getOperator(): string - { - return '$reverseArray'; - } } diff --git a/src/Builder/Expression/RoundOperator.php b/src/Builder/Expression/RoundOperator.php index 6df8dfdfc..21638126d 100644 --- a/src/Builder/Expression/RoundOperator.php +++ b/src/Builder/Expression/RoundOperator.php @@ -23,6 +23,7 @@ final class RoundOperator implements ResolvesToInt, ResolvesToDouble, ResolvesToDecimal, ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$round'; public const PROPERTIES = ['number' => 'number', 'place' => 'place']; /** @@ -46,9 +47,4 @@ public function __construct( $this->number = $number; $this->place = $place; } - - public function getOperator(): string - { - return '$round'; - } } diff --git a/src/Builder/Expression/RtrimOperator.php b/src/Builder/Expression/RtrimOperator.php index b48272947..46824f98a 100644 --- a/src/Builder/Expression/RtrimOperator.php +++ b/src/Builder/Expression/RtrimOperator.php @@ -21,6 +21,7 @@ final class RtrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$rtrim'; 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. */ @@ -46,9 +47,4 @@ public function __construct( $this->input = $input; $this->chars = $chars; } - - public function getOperator(): string - { - return '$rtrim'; - } } diff --git a/src/Builder/Expression/SecondOperator.php b/src/Builder/Expression/SecondOperator.php index 63df33467..720d57a92 100644 --- a/src/Builder/Expression/SecondOperator.php +++ b/src/Builder/Expression/SecondOperator.php @@ -24,6 +24,7 @@ final class SecondOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$second'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$second'; - } } diff --git a/src/Builder/Expression/SetDifferenceOperator.php b/src/Builder/Expression/SetDifferenceOperator.php index f340c3668..2b4fde506 100644 --- a/src/Builder/Expression/SetDifferenceOperator.php +++ b/src/Builder/Expression/SetDifferenceOperator.php @@ -26,6 +26,7 @@ final class SetDifferenceOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$setDifference'; 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. */ @@ -53,9 +54,4 @@ public function __construct( $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$setDifference'; - } } diff --git a/src/Builder/Expression/SetEqualsOperator.php b/src/Builder/Expression/SetEqualsOperator.php index 5099f33e4..b7eca0089 100644 --- a/src/Builder/Expression/SetEqualsOperator.php +++ b/src/Builder/Expression/SetEqualsOperator.php @@ -25,6 +25,7 @@ final class SetEqualsOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$setEquals'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -46,9 +47,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$setEquals'; - } } diff --git a/src/Builder/Expression/SetFieldOperator.php b/src/Builder/Expression/SetFieldOperator.php index 921c2f51c..08559253e 100644 --- a/src/Builder/Expression/SetFieldOperator.php +++ b/src/Builder/Expression/SetFieldOperator.php @@ -26,6 +26,7 @@ final class SetFieldOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$setField'; 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. */ @@ -55,9 +56,4 @@ public function __construct( $this->input = $input; $this->value = $value; } - - public function getOperator(): string - { - return '$setField'; - } } diff --git a/src/Builder/Expression/SetIntersectionOperator.php b/src/Builder/Expression/SetIntersectionOperator.php index a5d8116a4..3ec2c03dd 100644 --- a/src/Builder/Expression/SetIntersectionOperator.php +++ b/src/Builder/Expression/SetIntersectionOperator.php @@ -25,6 +25,7 @@ final class SetIntersectionOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$setIntersection'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -46,9 +47,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$setIntersection'; - } } diff --git a/src/Builder/Expression/SetIsSubsetOperator.php b/src/Builder/Expression/SetIsSubsetOperator.php index 7c2baeb40..76263d138 100644 --- a/src/Builder/Expression/SetIsSubsetOperator.php +++ b/src/Builder/Expression/SetIsSubsetOperator.php @@ -26,6 +26,7 @@ final class SetIsSubsetOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$setIsSubset'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var BSONArray|PackedArray|ResolvesToArray|array $expression1 */ @@ -53,9 +54,4 @@ public function __construct( $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$setIsSubset'; - } } diff --git a/src/Builder/Expression/SetUnionOperator.php b/src/Builder/Expression/SetUnionOperator.php index 132e2701b..62f2cb871 100644 --- a/src/Builder/Expression/SetUnionOperator.php +++ b/src/Builder/Expression/SetUnionOperator.php @@ -25,6 +25,7 @@ final class SetUnionOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$setUnion'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -46,9 +47,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$setUnion'; - } } diff --git a/src/Builder/Expression/SinOperator.php b/src/Builder/Expression/SinOperator.php index 76f72f4f0..9ba0d998e 100644 --- a/src/Builder/Expression/SinOperator.php +++ b/src/Builder/Expression/SinOperator.php @@ -22,6 +22,7 @@ final class SinOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sin'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$sin'; - } } diff --git a/src/Builder/Expression/SinhOperator.php b/src/Builder/Expression/SinhOperator.php index d5dfa929c..e04ff231d 100644 --- a/src/Builder/Expression/SinhOperator.php +++ b/src/Builder/Expression/SinhOperator.php @@ -22,6 +22,7 @@ final class SinhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sinh'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$sinh'; - } } diff --git a/src/Builder/Expression/SizeOperator.php b/src/Builder/Expression/SizeOperator.php index 964f420ac..7ff3b83f7 100644 --- a/src/Builder/Expression/SizeOperator.php +++ b/src/Builder/Expression/SizeOperator.php @@ -26,6 +26,7 @@ final class SizeOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$size'; 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. */ @@ -42,9 +43,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $express $this->expression = $expression; } - - public function getOperator(): string - { - return '$size'; - } } diff --git a/src/Builder/Expression/SliceOperator.php b/src/Builder/Expression/SliceOperator.php index 96599fcb1..220810428 100644 --- a/src/Builder/Expression/SliceOperator.php +++ b/src/Builder/Expression/SliceOperator.php @@ -27,6 +27,7 @@ final class SliceOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$slice'; 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. */ @@ -68,9 +69,4 @@ public function __construct( $this->n = $n; $this->position = $position; } - - public function getOperator(): string - { - return '$slice'; - } } diff --git a/src/Builder/Expression/SortArrayOperator.php b/src/Builder/Expression/SortArrayOperator.php index f85d07cc4..b58e2b65e 100644 --- a/src/Builder/Expression/SortArrayOperator.php +++ b/src/Builder/Expression/SortArrayOperator.php @@ -30,6 +30,7 @@ final class SortArrayOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$sortArray'; public const PROPERTIES = ['input' => 'input', 'sortBy' => 'sortBy']; /** @@ -59,9 +60,4 @@ public function __construct( $this->input = $input; $this->sortBy = $sortBy; } - - public function getOperator(): string - { - return '$sortArray'; - } } diff --git a/src/Builder/Expression/SplitOperator.php b/src/Builder/Expression/SplitOperator.php index e1e0b0cca..2e54ef5a5 100644 --- a/src/Builder/Expression/SplitOperator.php +++ b/src/Builder/Expression/SplitOperator.php @@ -20,6 +20,7 @@ final class SplitOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$split'; 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. */ @@ -37,9 +38,4 @@ public function __construct(ResolvesToString|string $string, ResolvesToString|st $this->string = $string; $this->delimiter = $delimiter; } - - public function getOperator(): string - { - return '$split'; - } } diff --git a/src/Builder/Expression/SqrtOperator.php b/src/Builder/Expression/SqrtOperator.php index 62f73fe0b..90a907ef5 100644 --- a/src/Builder/Expression/SqrtOperator.php +++ b/src/Builder/Expression/SqrtOperator.php @@ -22,6 +22,7 @@ final class SqrtOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sqrt'; 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. */ @@ -34,9 +35,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $number) { $this->number = $number; } - - public function getOperator(): string - { - return '$sqrt'; - } } diff --git a/src/Builder/Expression/StdDevPopOperator.php b/src/Builder/Expression/StdDevPopOperator.php index ab6bccecf..e966f8e84 100644 --- a/src/Builder/Expression/StdDevPopOperator.php +++ b/src/Builder/Expression/StdDevPopOperator.php @@ -27,6 +27,7 @@ final class StdDevPopOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$stdDevPop'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -48,9 +49,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$stdDevPop'; - } } diff --git a/src/Builder/Expression/StdDevSampOperator.php b/src/Builder/Expression/StdDevSampOperator.php index 0c4e31a68..1c897728b 100644 --- a/src/Builder/Expression/StdDevSampOperator.php +++ b/src/Builder/Expression/StdDevSampOperator.php @@ -26,6 +26,7 @@ final class StdDevSampOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$stdDevSamp'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -47,9 +48,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int ...$expr $this->expression = $expression; } - - public function getOperator(): string - { - return '$stdDevSamp'; - } } diff --git a/src/Builder/Expression/StrLenBytesOperator.php b/src/Builder/Expression/StrLenBytesOperator.php index 26e899e99..39ae8dbe8 100644 --- a/src/Builder/Expression/StrLenBytesOperator.php +++ b/src/Builder/Expression/StrLenBytesOperator.php @@ -20,6 +20,7 @@ final class StrLenBytesOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$strLenBytes'; public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ @@ -32,9 +33,4 @@ public function __construct(ResolvesToString|string $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$strLenBytes'; - } } diff --git a/src/Builder/Expression/StrLenCPOperator.php b/src/Builder/Expression/StrLenCPOperator.php index b6d97c37a..8add7c3f8 100644 --- a/src/Builder/Expression/StrLenCPOperator.php +++ b/src/Builder/Expression/StrLenCPOperator.php @@ -20,6 +20,7 @@ final class StrLenCPOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$strLenCP'; public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ @@ -32,9 +33,4 @@ public function __construct(ResolvesToString|string $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$strLenCP'; - } } diff --git a/src/Builder/Expression/StrcasecmpOperator.php b/src/Builder/Expression/StrcasecmpOperator.php index 2090cdda1..efcb0e41b 100644 --- a/src/Builder/Expression/StrcasecmpOperator.php +++ b/src/Builder/Expression/StrcasecmpOperator.php @@ -20,6 +20,7 @@ final class StrcasecmpOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$strcasecmp'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var ResolvesToString|string $expression1 */ @@ -37,9 +38,4 @@ public function __construct(ResolvesToString|string $expression1, ResolvesToStri $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$strcasecmp'; - } } diff --git a/src/Builder/Expression/SubstrBytesOperator.php b/src/Builder/Expression/SubstrBytesOperator.php index 9d20afe67..72d5ee8c5 100644 --- a/src/Builder/Expression/SubstrBytesOperator.php +++ b/src/Builder/Expression/SubstrBytesOperator.php @@ -20,6 +20,7 @@ final class SubstrBytesOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$substrBytes'; public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; /** @var ResolvesToString|string $string */ @@ -42,9 +43,4 @@ public function __construct(ResolvesToString|string $string, ResolvesToInt|int $ $this->start = $start; $this->length = $length; } - - public function getOperator(): string - { - return '$substrBytes'; - } } diff --git a/src/Builder/Expression/SubstrCPOperator.php b/src/Builder/Expression/SubstrCPOperator.php index 93af8d80c..ee01339d2 100644 --- a/src/Builder/Expression/SubstrCPOperator.php +++ b/src/Builder/Expression/SubstrCPOperator.php @@ -20,6 +20,7 @@ final class SubstrCPOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$substrCP'; public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; /** @var ResolvesToString|string $string */ @@ -42,9 +43,4 @@ public function __construct(ResolvesToString|string $string, ResolvesToInt|int $ $this->start = $start; $this->length = $length; } - - public function getOperator(): string - { - return '$substrCP'; - } } diff --git a/src/Builder/Expression/SubstrOperator.php b/src/Builder/Expression/SubstrOperator.php index 6f34320dc..10ece1704 100644 --- a/src/Builder/Expression/SubstrOperator.php +++ b/src/Builder/Expression/SubstrOperator.php @@ -20,6 +20,7 @@ final class SubstrOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$substr'; public const PROPERTIES = ['string' => 'string', 'start' => 'start', 'length' => 'length']; /** @var ResolvesToString|string $string */ @@ -42,9 +43,4 @@ public function __construct(ResolvesToString|string $string, ResolvesToInt|int $ $this->start = $start; $this->length = $length; } - - public function getOperator(): string - { - return '$substr'; - } } diff --git a/src/Builder/Expression/SubtractOperator.php b/src/Builder/Expression/SubtractOperator.php index 35b1075d4..8a7187b78 100644 --- a/src/Builder/Expression/SubtractOperator.php +++ b/src/Builder/Expression/SubtractOperator.php @@ -23,6 +23,7 @@ final class SubtractOperator implements ResolvesToInt, ResolvesToLong, ResolvesToDouble, ResolvesToDecimal, ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$subtract'; public const PROPERTIES = ['expression1' => 'expression1', 'expression2' => 'expression2']; /** @var Decimal128|Int64|ResolvesToDate|ResolvesToNumber|UTCDateTime|float|int $expression1 */ @@ -42,9 +43,4 @@ public function __construct( $this->expression1 = $expression1; $this->expression2 = $expression2; } - - public function getOperator(): string - { - return '$subtract'; - } } diff --git a/src/Builder/Expression/SumOperator.php b/src/Builder/Expression/SumOperator.php index ccf797785..99d90de28 100644 --- a/src/Builder/Expression/SumOperator.php +++ b/src/Builder/Expression/SumOperator.php @@ -28,6 +28,7 @@ final class SumOperator implements ResolvesToNumber, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sum'; public const PROPERTIES = ['expression' => 'expression']; /** @var list $expression */ @@ -50,9 +51,4 @@ public function __construct( $this->expression = $expression; } - - public function getOperator(): string - { - return '$sum'; - } } diff --git a/src/Builder/Expression/SwitchOperator.php b/src/Builder/Expression/SwitchOperator.php index e8450ebdb..4179a5d52 100644 --- a/src/Builder/Expression/SwitchOperator.php +++ b/src/Builder/Expression/SwitchOperator.php @@ -30,6 +30,7 @@ final class SwitchOperator implements ResolvesToAny, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$switch'; public const PROPERTIES = ['branches' => 'branches', 'default' => 'default']; /** @@ -65,9 +66,4 @@ public function __construct( $this->branches = $branches; $this->default = $default; } - - public function getOperator(): string - { - return '$switch'; - } } diff --git a/src/Builder/Expression/TanOperator.php b/src/Builder/Expression/TanOperator.php index f0f8c9bce..bab27a3a5 100644 --- a/src/Builder/Expression/TanOperator.php +++ b/src/Builder/Expression/TanOperator.php @@ -22,6 +22,7 @@ final class TanOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$tan'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$tan'; - } } diff --git a/src/Builder/Expression/TanhOperator.php b/src/Builder/Expression/TanhOperator.php index e94baa97f..5e31a67d1 100644 --- a/src/Builder/Expression/TanhOperator.php +++ b/src/Builder/Expression/TanhOperator.php @@ -22,6 +22,7 @@ final class TanhOperator implements ResolvesToDouble, ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$tanh'; public const PROPERTIES = ['expression' => 'expression']; /** @@ -38,9 +39,4 @@ public function __construct(Decimal128|Int64|ResolvesToNumber|float|int $express { $this->expression = $expression; } - - public function getOperator(): string - { - return '$tanh'; - } } diff --git a/src/Builder/Expression/ToBoolOperator.php b/src/Builder/Expression/ToBoolOperator.php index 364a6f805..15416abc6 100644 --- a/src/Builder/Expression/ToBoolOperator.php +++ b/src/Builder/Expression/ToBoolOperator.php @@ -24,6 +24,7 @@ final class ToBoolOperator implements ResolvesToBool, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toBool'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toBool'; - } } diff --git a/src/Builder/Expression/ToDateOperator.php b/src/Builder/Expression/ToDateOperator.php index d94782a55..10e36c4af 100644 --- a/src/Builder/Expression/ToDateOperator.php +++ b/src/Builder/Expression/ToDateOperator.php @@ -24,6 +24,7 @@ final class ToDateOperator implements ResolvesToDate, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toDate'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toDate'; - } } diff --git a/src/Builder/Expression/ToDecimalOperator.php b/src/Builder/Expression/ToDecimalOperator.php index f4e5ee3cd..a10075ef6 100644 --- a/src/Builder/Expression/ToDecimalOperator.php +++ b/src/Builder/Expression/ToDecimalOperator.php @@ -24,6 +24,7 @@ final class ToDecimalOperator implements ResolvesToDecimal, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toDecimal'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toDecimal'; - } } diff --git a/src/Builder/Expression/ToDoubleOperator.php b/src/Builder/Expression/ToDoubleOperator.php index c411a52d5..0b90d8732 100644 --- a/src/Builder/Expression/ToDoubleOperator.php +++ b/src/Builder/Expression/ToDoubleOperator.php @@ -24,6 +24,7 @@ final class ToDoubleOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toDouble'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toDouble'; - } } diff --git a/src/Builder/Expression/ToHashedIndexKeyOperator.php b/src/Builder/Expression/ToHashedIndexKeyOperator.php index ad41fc8b1..c6219e0dd 100644 --- a/src/Builder/Expression/ToHashedIndexKeyOperator.php +++ b/src/Builder/Expression/ToHashedIndexKeyOperator.php @@ -23,6 +23,7 @@ final class ToHashedIndexKeyOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toHashedIndexKey'; public const PROPERTIES = ['value' => 'value']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $value key or string to hash */ @@ -35,9 +36,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->value = $value; } - - public function getOperator(): string - { - return '$toHashedIndexKey'; - } } diff --git a/src/Builder/Expression/ToIntOperator.php b/src/Builder/Expression/ToIntOperator.php index 1d7f6538a..b4cd77f20 100644 --- a/src/Builder/Expression/ToIntOperator.php +++ b/src/Builder/Expression/ToIntOperator.php @@ -24,6 +24,7 @@ final class ToIntOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toInt'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toInt'; - } } diff --git a/src/Builder/Expression/ToLongOperator.php b/src/Builder/Expression/ToLongOperator.php index 54acf0052..a386d0c63 100644 --- a/src/Builder/Expression/ToLongOperator.php +++ b/src/Builder/Expression/ToLongOperator.php @@ -24,6 +24,7 @@ final class ToLongOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toLong'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toLong'; - } } diff --git a/src/Builder/Expression/ToLowerOperator.php b/src/Builder/Expression/ToLowerOperator.php index 83ff37e66..500605889 100644 --- a/src/Builder/Expression/ToLowerOperator.php +++ b/src/Builder/Expression/ToLowerOperator.php @@ -20,6 +20,7 @@ final class ToLowerOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toLower'; public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ @@ -32,9 +33,4 @@ public function __construct(ResolvesToString|string $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toLower'; - } } diff --git a/src/Builder/Expression/ToObjectIdOperator.php b/src/Builder/Expression/ToObjectIdOperator.php index f820a3d55..cdc95d275 100644 --- a/src/Builder/Expression/ToObjectIdOperator.php +++ b/src/Builder/Expression/ToObjectIdOperator.php @@ -24,6 +24,7 @@ final class ToObjectIdOperator implements ResolvesToObjectId, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toObjectId'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toObjectId'; - } } diff --git a/src/Builder/Expression/ToStringOperator.php b/src/Builder/Expression/ToStringOperator.php index 8c0a47bbf..802112cb6 100644 --- a/src/Builder/Expression/ToStringOperator.php +++ b/src/Builder/Expression/ToStringOperator.php @@ -24,6 +24,7 @@ final class ToStringOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toString'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toString'; - } } diff --git a/src/Builder/Expression/ToUpperOperator.php b/src/Builder/Expression/ToUpperOperator.php index 93e896b09..604711964 100644 --- a/src/Builder/Expression/ToUpperOperator.php +++ b/src/Builder/Expression/ToUpperOperator.php @@ -20,6 +20,7 @@ final class ToUpperOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$toUpper'; public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToString|string $expression */ @@ -32,9 +33,4 @@ public function __construct(ResolvesToString|string $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$toUpper'; - } } diff --git a/src/Builder/Expression/TrimOperator.php b/src/Builder/Expression/TrimOperator.php index c524bdfe0..0b210e467 100644 --- a/src/Builder/Expression/TrimOperator.php +++ b/src/Builder/Expression/TrimOperator.php @@ -22,6 +22,7 @@ final class TrimOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$trim'; 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. */ @@ -47,9 +48,4 @@ public function __construct( $this->input = $input; $this->chars = $chars; } - - public function getOperator(): string - { - return '$trim'; - } } diff --git a/src/Builder/Expression/TruncOperator.php b/src/Builder/Expression/TruncOperator.php index df988e622..c6db92b34 100644 --- a/src/Builder/Expression/TruncOperator.php +++ b/src/Builder/Expression/TruncOperator.php @@ -23,6 +23,7 @@ final class TruncOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$trunc'; public const PROPERTIES = ['number' => 'number', 'place' => 'place']; /** @@ -46,9 +47,4 @@ public function __construct( $this->number = $number; $this->place = $place; } - - public function getOperator(): string - { - return '$trunc'; - } } diff --git a/src/Builder/Expression/TsIncrementOperator.php b/src/Builder/Expression/TsIncrementOperator.php index 677a30375..b39d897bc 100644 --- a/src/Builder/Expression/TsIncrementOperator.php +++ b/src/Builder/Expression/TsIncrementOperator.php @@ -22,6 +22,7 @@ final class TsIncrementOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$tsIncrement'; public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToTimestamp|Timestamp|int $expression */ @@ -34,9 +35,4 @@ public function __construct(Timestamp|ResolvesToTimestamp|int $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$tsIncrement'; - } } diff --git a/src/Builder/Expression/TsSecondOperator.php b/src/Builder/Expression/TsSecondOperator.php index 3c3a995d8..71af2b803 100644 --- a/src/Builder/Expression/TsSecondOperator.php +++ b/src/Builder/Expression/TsSecondOperator.php @@ -22,6 +22,7 @@ final class TsSecondOperator implements ResolvesToLong, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$tsSecond'; public const PROPERTIES = ['expression' => 'expression']; /** @var ResolvesToTimestamp|Timestamp|int $expression */ @@ -34,9 +35,4 @@ public function __construct(Timestamp|ResolvesToTimestamp|int $expression) { $this->expression = $expression; } - - public function getOperator(): string - { - return '$tsSecond'; - } } diff --git a/src/Builder/Expression/TypeOperator.php b/src/Builder/Expression/TypeOperator.php index 516b1a0af..34457be7c 100644 --- a/src/Builder/Expression/TypeOperator.php +++ b/src/Builder/Expression/TypeOperator.php @@ -23,6 +23,7 @@ final class TypeOperator implements ResolvesToString, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$type'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -35,9 +36,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$type'; - } } diff --git a/src/Builder/Expression/UnsetFieldOperator.php b/src/Builder/Expression/UnsetFieldOperator.php index da5fdf4ac..6b040e2c4 100644 --- a/src/Builder/Expression/UnsetFieldOperator.php +++ b/src/Builder/Expression/UnsetFieldOperator.php @@ -24,6 +24,7 @@ final class UnsetFieldOperator implements ResolvesToObject, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$unsetField'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->field = $field; $this->input = $input; } - - public function getOperator(): string - { - return '$unsetField'; - } } diff --git a/src/Builder/Expression/WeekOperator.php b/src/Builder/Expression/WeekOperator.php index 006e3371d..2d58d0509 100644 --- a/src/Builder/Expression/WeekOperator.php +++ b/src/Builder/Expression/WeekOperator.php @@ -24,6 +24,7 @@ final class WeekOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$week'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$week'; - } } diff --git a/src/Builder/Expression/YearOperator.php b/src/Builder/Expression/YearOperator.php index 4b7d98f7f..57fcb35ae 100644 --- a/src/Builder/Expression/YearOperator.php +++ b/src/Builder/Expression/YearOperator.php @@ -24,6 +24,7 @@ final class YearOperator implements ResolvesToInt, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$year'; 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. */ @@ -43,9 +44,4 @@ public function __construct( $this->date = $date; $this->timezone = $timezone; } - - public function getOperator(): string - { - return '$year'; - } } diff --git a/src/Builder/Expression/ZipOperator.php b/src/Builder/Expression/ZipOperator.php index 591c0c125..742b7e6bf 100644 --- a/src/Builder/Expression/ZipOperator.php +++ b/src/Builder/Expression/ZipOperator.php @@ -27,6 +27,7 @@ final class ZipOperator implements ResolvesToArray, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$zip'; public const PROPERTIES = ['inputs' => 'inputs', 'useLongestLength' => 'useLongestLength', 'defaults' => 'defaults']; /** @@ -76,9 +77,4 @@ public function __construct( $this->defaults = $defaults; } - - public function getOperator(): string - { - return '$zip'; - } } diff --git a/src/Builder/Query/AllOperator.php b/src/Builder/Query/AllOperator.php index 558cfea3b..db84daf0a 100644 --- a/src/Builder/Query/AllOperator.php +++ b/src/Builder/Query/AllOperator.php @@ -26,6 +26,7 @@ final class AllOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$all'; public const PROPERTIES = ['value' => 'value']; /** @var list $value */ @@ -47,9 +48,4 @@ public function __construct(Type|FieldQueryInterface|stdClass|array|bool|float|i $this->value = $value; } - - public function getOperator(): string - { - return '$all'; - } } diff --git a/src/Builder/Query/AndOperator.php b/src/Builder/Query/AndOperator.php index 7ed9b0d6d..8738591be 100644 --- a/src/Builder/Query/AndOperator.php +++ b/src/Builder/Query/AndOperator.php @@ -24,6 +24,7 @@ final class AndOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$and'; public const PROPERTIES = ['queries' => 'queries']; /** @var list $queries */ @@ -45,9 +46,4 @@ public function __construct(QueryInterface|array ...$queries) $this->queries = $queries; } - - public function getOperator(): string - { - return '$and'; - } } diff --git a/src/Builder/Query/BitsAllClearOperator.php b/src/Builder/Query/BitsAllClearOperator.php index ad781b6bd..072c031bb 100644 --- a/src/Builder/Query/BitsAllClearOperator.php +++ b/src/Builder/Query/BitsAllClearOperator.php @@ -28,6 +28,7 @@ final class BitsAllClearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitsAllClear'; public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ @@ -44,9 +45,4 @@ public function __construct(Binary|PackedArray|BSONArray|array|int|string $bitma $this->bitmask = $bitmask; } - - public function getOperator(): string - { - return '$bitsAllClear'; - } } diff --git a/src/Builder/Query/BitsAllSetOperator.php b/src/Builder/Query/BitsAllSetOperator.php index f28d7aaaa..a90e12f35 100644 --- a/src/Builder/Query/BitsAllSetOperator.php +++ b/src/Builder/Query/BitsAllSetOperator.php @@ -28,6 +28,7 @@ final class BitsAllSetOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitsAllSet'; public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ @@ -44,9 +45,4 @@ public function __construct(Binary|PackedArray|BSONArray|array|int|string $bitma $this->bitmask = $bitmask; } - - public function getOperator(): string - { - return '$bitsAllSet'; - } } diff --git a/src/Builder/Query/BitsAnyClearOperator.php b/src/Builder/Query/BitsAnyClearOperator.php index cf6a4baa1..0ae56d93a 100644 --- a/src/Builder/Query/BitsAnyClearOperator.php +++ b/src/Builder/Query/BitsAnyClearOperator.php @@ -28,6 +28,7 @@ final class BitsAnyClearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitsAnyClear'; public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ @@ -44,9 +45,4 @@ public function __construct(Binary|PackedArray|BSONArray|array|int|string $bitma $this->bitmask = $bitmask; } - - public function getOperator(): string - { - return '$bitsAnyClear'; - } } diff --git a/src/Builder/Query/BitsAnySetOperator.php b/src/Builder/Query/BitsAnySetOperator.php index 64a3e3e48..5a202c9d4 100644 --- a/src/Builder/Query/BitsAnySetOperator.php +++ b/src/Builder/Query/BitsAnySetOperator.php @@ -28,6 +28,7 @@ final class BitsAnySetOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$bitsAnySet'; public const PROPERTIES = ['bitmask' => 'bitmask']; /** @var BSONArray|Binary|PackedArray|array|int|string $bitmask */ @@ -44,9 +45,4 @@ public function __construct(Binary|PackedArray|BSONArray|array|int|string $bitma $this->bitmask = $bitmask; } - - public function getOperator(): string - { - return '$bitsAnySet'; - } } diff --git a/src/Builder/Query/BoxOperator.php b/src/Builder/Query/BoxOperator.php index 8e07cfe5a..cce9cf8d8 100644 --- a/src/Builder/Query/BoxOperator.php +++ b/src/Builder/Query/BoxOperator.php @@ -27,6 +27,7 @@ final class BoxOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$box'; public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ @@ -43,9 +44,4 @@ public function __construct(PackedArray|BSONArray|array $value) $this->value = $value; } - - public function getOperator(): string - { - return '$box'; - } } diff --git a/src/Builder/Query/CenterOperator.php b/src/Builder/Query/CenterOperator.php index e9c4b057a..f3a0b890a 100644 --- a/src/Builder/Query/CenterOperator.php +++ b/src/Builder/Query/CenterOperator.php @@ -27,6 +27,7 @@ final class CenterOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$center'; public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ @@ -43,9 +44,4 @@ public function __construct(PackedArray|BSONArray|array $value) $this->value = $value; } - - public function getOperator(): string - { - return '$center'; - } } diff --git a/src/Builder/Query/CenterSphereOperator.php b/src/Builder/Query/CenterSphereOperator.php index 373cf2190..350f535f0 100644 --- a/src/Builder/Query/CenterSphereOperator.php +++ b/src/Builder/Query/CenterSphereOperator.php @@ -27,6 +27,7 @@ final class CenterSphereOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$centerSphere'; public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ @@ -43,9 +44,4 @@ public function __construct(PackedArray|BSONArray|array $value) $this->value = $value; } - - public function getOperator(): string - { - return '$centerSphere'; - } } diff --git a/src/Builder/Query/CommentOperator.php b/src/Builder/Query/CommentOperator.php index 58ba0c126..938498039 100644 --- a/src/Builder/Query/CommentOperator.php +++ b/src/Builder/Query/CommentOperator.php @@ -21,6 +21,7 @@ final class CommentOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$comment'; public const PROPERTIES = ['comment' => 'comment']; /** @var string $comment */ @@ -33,9 +34,4 @@ public function __construct(string $comment) { $this->comment = $comment; } - - public function getOperator(): string - { - return '$comment'; - } } diff --git a/src/Builder/Query/ElemMatchOperator.php b/src/Builder/Query/ElemMatchOperator.php index e56b1e43c..b2195d269 100644 --- a/src/Builder/Query/ElemMatchOperator.php +++ b/src/Builder/Query/ElemMatchOperator.php @@ -27,6 +27,7 @@ final class ElemMatchOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$elemMatch'; public const PROPERTIES = ['query' => 'query']; /** @var FieldQueryInterface|QueryInterface|Type|array|bool|float|int|null|stdClass|string $query */ @@ -44,9 +45,4 @@ public function __construct( $this->query = $query; } - - public function getOperator(): string - { - return '$elemMatch'; - } } diff --git a/src/Builder/Query/EqOperator.php b/src/Builder/Query/EqOperator.php index ba7b530a3..2b38feed8 100644 --- a/src/Builder/Query/EqOperator.php +++ b/src/Builder/Query/EqOperator.php @@ -23,6 +23,7 @@ final class EqOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$eq'; public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ @@ -35,9 +36,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$eq'; - } } diff --git a/src/Builder/Query/ExistsOperator.php b/src/Builder/Query/ExistsOperator.php index 21178931c..1d0b0a292 100644 --- a/src/Builder/Query/ExistsOperator.php +++ b/src/Builder/Query/ExistsOperator.php @@ -21,6 +21,7 @@ final class ExistsOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$exists'; public const PROPERTIES = ['exists' => 'exists']; /** @var bool $exists */ @@ -33,9 +34,4 @@ public function __construct(bool $exists = true) { $this->exists = $exists; } - - public function getOperator(): string - { - return '$exists'; - } } diff --git a/src/Builder/Query/ExprOperator.php b/src/Builder/Query/ExprOperator.php index bea9c861d..9e8350a98 100644 --- a/src/Builder/Query/ExprOperator.php +++ b/src/Builder/Query/ExprOperator.php @@ -24,6 +24,7 @@ final class ExprOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$expr'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$expr'; - } } diff --git a/src/Builder/Query/GeoIntersectsOperator.php b/src/Builder/Query/GeoIntersectsOperator.php index c5e4b67c9..37cad3eae 100644 --- a/src/Builder/Query/GeoIntersectsOperator.php +++ b/src/Builder/Query/GeoIntersectsOperator.php @@ -25,6 +25,7 @@ final class GeoIntersectsOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$geoIntersects'; public const PROPERTIES = ['geometry' => null]; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ @@ -37,9 +38,4 @@ public function __construct(Document|Serializable|GeometryInterface|stdClass|arr { $this->geometry = $geometry; } - - public function getOperator(): string - { - return '$geoIntersects'; - } } diff --git a/src/Builder/Query/GeoWithinOperator.php b/src/Builder/Query/GeoWithinOperator.php index 4e0dae8b2..258592f00 100644 --- a/src/Builder/Query/GeoWithinOperator.php +++ b/src/Builder/Query/GeoWithinOperator.php @@ -25,6 +25,7 @@ final class GeoWithinOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$geoWithin'; public const PROPERTIES = ['geometry' => null]; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ @@ -37,9 +38,4 @@ public function __construct(Document|Serializable|GeometryInterface|stdClass|arr { $this->geometry = $geometry; } - - public function getOperator(): string - { - return '$geoWithin'; - } } diff --git a/src/Builder/Query/GeometryOperator.php b/src/Builder/Query/GeometryOperator.php index 7430fe0ef..fe52be973 100644 --- a/src/Builder/Query/GeometryOperator.php +++ b/src/Builder/Query/GeometryOperator.php @@ -31,6 +31,7 @@ final class GeometryOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$geometry'; public const PROPERTIES = ['type' => 'type', 'coordinates' => 'coordinates', 'crs' => 'crs']; /** @var string $type */ @@ -60,9 +61,4 @@ public function __construct( $this->coordinates = $coordinates; $this->crs = $crs; } - - public function getOperator(): string - { - return '$geometry'; - } } diff --git a/src/Builder/Query/GtOperator.php b/src/Builder/Query/GtOperator.php index 8e1c783ed..5f79cd078 100644 --- a/src/Builder/Query/GtOperator.php +++ b/src/Builder/Query/GtOperator.php @@ -23,6 +23,7 @@ final class GtOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$gt'; public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ @@ -35,9 +36,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$gt'; - } } diff --git a/src/Builder/Query/GteOperator.php b/src/Builder/Query/GteOperator.php index 59c992127..00606e571 100644 --- a/src/Builder/Query/GteOperator.php +++ b/src/Builder/Query/GteOperator.php @@ -23,6 +23,7 @@ final class GteOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$gte'; public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ @@ -35,9 +36,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$gte'; - } } diff --git a/src/Builder/Query/InOperator.php b/src/Builder/Query/InOperator.php index 60d90b4db..e6f1456a4 100644 --- a/src/Builder/Query/InOperator.php +++ b/src/Builder/Query/InOperator.php @@ -27,6 +27,7 @@ final class InOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$in'; public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ @@ -43,9 +44,4 @@ public function __construct(PackedArray|BSONArray|array $value) $this->value = $value; } - - public function getOperator(): string - { - return '$in'; - } } diff --git a/src/Builder/Query/JsonSchemaOperator.php b/src/Builder/Query/JsonSchemaOperator.php index aea2de45d..3dc8b918e 100644 --- a/src/Builder/Query/JsonSchemaOperator.php +++ b/src/Builder/Query/JsonSchemaOperator.php @@ -24,6 +24,7 @@ final class JsonSchemaOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$jsonSchema'; public const PROPERTIES = ['schema' => 'schema']; /** @var Document|Serializable|array|stdClass $schema */ @@ -36,9 +37,4 @@ public function __construct(Document|Serializable|stdClass|array $schema) { $this->schema = $schema; } - - public function getOperator(): string - { - return '$jsonSchema'; - } } diff --git a/src/Builder/Query/LtOperator.php b/src/Builder/Query/LtOperator.php index f34bc688b..ac4e88a95 100644 --- a/src/Builder/Query/LtOperator.php +++ b/src/Builder/Query/LtOperator.php @@ -23,6 +23,7 @@ final class LtOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$lt'; public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ @@ -35,9 +36,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$lt'; - } } diff --git a/src/Builder/Query/LteOperator.php b/src/Builder/Query/LteOperator.php index f671bd228..2c8a7cf6f 100644 --- a/src/Builder/Query/LteOperator.php +++ b/src/Builder/Query/LteOperator.php @@ -23,6 +23,7 @@ final class LteOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$lte'; public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ @@ -35,9 +36,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$lte'; - } } diff --git a/src/Builder/Query/MaxDistanceOperator.php b/src/Builder/Query/MaxDistanceOperator.php index 5372f7bbf..2aea7d4c8 100644 --- a/src/Builder/Query/MaxDistanceOperator.php +++ b/src/Builder/Query/MaxDistanceOperator.php @@ -23,6 +23,7 @@ final class MaxDistanceOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$maxDistance'; public const PROPERTIES = ['value' => 'value']; /** @var Decimal128|Int64|float|int $value */ @@ -35,9 +36,4 @@ public function __construct(Decimal128|Int64|float|int $value) { $this->value = $value; } - - public function getOperator(): string - { - return '$maxDistance'; - } } diff --git a/src/Builder/Query/MinDistanceOperator.php b/src/Builder/Query/MinDistanceOperator.php index bd963a84d..74aadb397 100644 --- a/src/Builder/Query/MinDistanceOperator.php +++ b/src/Builder/Query/MinDistanceOperator.php @@ -22,6 +22,7 @@ final class MinDistanceOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$minDistance'; public const PROPERTIES = ['value' => 'value']; /** @var Int64|float|int $value */ @@ -34,9 +35,4 @@ public function __construct(Int64|float|int $value) { $this->value = $value; } - - public function getOperator(): string - { - return '$minDistance'; - } } diff --git a/src/Builder/Query/ModOperator.php b/src/Builder/Query/ModOperator.php index a6890965a..bbabdfdc9 100644 --- a/src/Builder/Query/ModOperator.php +++ b/src/Builder/Query/ModOperator.php @@ -23,6 +23,7 @@ final class ModOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Array; + public const NAME = '$mod'; public const PROPERTIES = ['divisor' => 'divisor', 'remainder' => 'remainder']; /** @var Decimal128|Int64|float|int $divisor */ @@ -40,9 +41,4 @@ public function __construct(Decimal128|Int64|float|int $divisor, Decimal128|Int6 $this->divisor = $divisor; $this->remainder = $remainder; } - - public function getOperator(): string - { - return '$mod'; - } } diff --git a/src/Builder/Query/NeOperator.php b/src/Builder/Query/NeOperator.php index 72861b76f..58cdc129c 100644 --- a/src/Builder/Query/NeOperator.php +++ b/src/Builder/Query/NeOperator.php @@ -23,6 +23,7 @@ final class NeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$ne'; public const PROPERTIES = ['value' => 'value']; /** @var Type|array|bool|float|int|null|stdClass|string $value */ @@ -35,9 +36,4 @@ public function __construct(Type|stdClass|array|bool|float|int|null|string $valu { $this->value = $value; } - - public function getOperator(): string - { - return '$ne'; - } } diff --git a/src/Builder/Query/NearOperator.php b/src/Builder/Query/NearOperator.php index 4807716fe..85be90ac4 100644 --- a/src/Builder/Query/NearOperator.php +++ b/src/Builder/Query/NearOperator.php @@ -28,6 +28,7 @@ final class NearOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$near'; public const PROPERTIES = ['geometry' => null, 'maxDistance' => '$maxDistance', 'minDistance' => '$minDistance']; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ @@ -53,9 +54,4 @@ public function __construct( $this->maxDistance = $maxDistance; $this->minDistance = $minDistance; } - - public function getOperator(): string - { - return '$near'; - } } diff --git a/src/Builder/Query/NearSphereOperator.php b/src/Builder/Query/NearSphereOperator.php index 71af4c489..5494048b0 100644 --- a/src/Builder/Query/NearSphereOperator.php +++ b/src/Builder/Query/NearSphereOperator.php @@ -28,6 +28,7 @@ final class NearSphereOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$nearSphere'; public const PROPERTIES = ['geometry' => null, 'maxDistance' => '$maxDistance', 'minDistance' => '$minDistance']; /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ @@ -53,9 +54,4 @@ public function __construct( $this->maxDistance = $maxDistance; $this->minDistance = $minDistance; } - - public function getOperator(): string - { - return '$nearSphere'; - } } diff --git a/src/Builder/Query/NinOperator.php b/src/Builder/Query/NinOperator.php index f1a50bd39..5c82c3fd8 100644 --- a/src/Builder/Query/NinOperator.php +++ b/src/Builder/Query/NinOperator.php @@ -27,6 +27,7 @@ final class NinOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$nin'; public const PROPERTIES = ['value' => 'value']; /** @var BSONArray|PackedArray|array $value */ @@ -43,9 +44,4 @@ public function __construct(PackedArray|BSONArray|array $value) $this->value = $value; } - - public function getOperator(): string - { - return '$nin'; - } } diff --git a/src/Builder/Query/NorOperator.php b/src/Builder/Query/NorOperator.php index 4fdf9e3e1..06bdc7e39 100644 --- a/src/Builder/Query/NorOperator.php +++ b/src/Builder/Query/NorOperator.php @@ -24,6 +24,7 @@ final class NorOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$nor'; public const PROPERTIES = ['queries' => 'queries']; /** @var list $queries */ @@ -45,9 +46,4 @@ public function __construct(QueryInterface|array ...$queries) $this->queries = $queries; } - - public function getOperator(): string - { - return '$nor'; - } } diff --git a/src/Builder/Query/NotOperator.php b/src/Builder/Query/NotOperator.php index ee3c12d34..f3b422f24 100644 --- a/src/Builder/Query/NotOperator.php +++ b/src/Builder/Query/NotOperator.php @@ -23,6 +23,7 @@ final class NotOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$not'; public const PROPERTIES = ['expression' => 'expression']; /** @var FieldQueryInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -35,9 +36,4 @@ public function __construct(Type|FieldQueryInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$not'; - } } diff --git a/src/Builder/Query/OrOperator.php b/src/Builder/Query/OrOperator.php index a9d246a9f..1b922fdb4 100644 --- a/src/Builder/Query/OrOperator.php +++ b/src/Builder/Query/OrOperator.php @@ -24,6 +24,7 @@ final class OrOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$or'; public const PROPERTIES = ['queries' => 'queries']; /** @var list $queries */ @@ -45,9 +46,4 @@ public function __construct(QueryInterface|array ...$queries) $this->queries = $queries; } - - public function getOperator(): string - { - return '$or'; - } } diff --git a/src/Builder/Query/PolygonOperator.php b/src/Builder/Query/PolygonOperator.php index a512a5259..bba3aac08 100644 --- a/src/Builder/Query/PolygonOperator.php +++ b/src/Builder/Query/PolygonOperator.php @@ -27,6 +27,7 @@ final class PolygonOperator implements GeometryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$polygon'; public const PROPERTIES = ['points' => 'points']; /** @var BSONArray|PackedArray|array $points */ @@ -43,9 +44,4 @@ public function __construct(PackedArray|BSONArray|array $points) $this->points = $points; } - - public function getOperator(): string - { - return '$polygon'; - } } diff --git a/src/Builder/Query/RandOperator.php b/src/Builder/Query/RandOperator.php index 7cea63382..ccf8a8d28 100644 --- a/src/Builder/Query/RandOperator.php +++ b/src/Builder/Query/RandOperator.php @@ -21,13 +21,9 @@ final class RandOperator implements ResolvesToDouble, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$rand'; public function __construct() { } - - public function getOperator(): string - { - return '$rand'; - } } diff --git a/src/Builder/Query/RegexOperator.php b/src/Builder/Query/RegexOperator.php index e0addbbb0..cf9ee31ff 100644 --- a/src/Builder/Query/RegexOperator.php +++ b/src/Builder/Query/RegexOperator.php @@ -22,6 +22,7 @@ final class RegexOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$regex'; public const PROPERTIES = ['regex' => 'regex']; /** @var Regex $regex */ @@ -34,9 +35,4 @@ public function __construct(Regex $regex) { $this->regex = $regex; } - - public function getOperator(): string - { - return '$regex'; - } } diff --git a/src/Builder/Query/SampleRateOperator.php b/src/Builder/Query/SampleRateOperator.php index df559bb9b..42879cead 100644 --- a/src/Builder/Query/SampleRateOperator.php +++ b/src/Builder/Query/SampleRateOperator.php @@ -23,6 +23,7 @@ final class SampleRateOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sampleRate'; public const PROPERTIES = ['rate' => 'rate']; /** @@ -39,9 +40,4 @@ public function __construct(Int64|ResolvesToDouble|float|int $rate) { $this->rate = $rate; } - - public function getOperator(): string - { - return '$sampleRate'; - } } diff --git a/src/Builder/Query/SizeOperator.php b/src/Builder/Query/SizeOperator.php index 00da6f3e2..8ec123b11 100644 --- a/src/Builder/Query/SizeOperator.php +++ b/src/Builder/Query/SizeOperator.php @@ -21,6 +21,7 @@ final class SizeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$size'; public const PROPERTIES = ['value' => 'value']; /** @var int $value */ @@ -33,9 +34,4 @@ public function __construct(int $value) { $this->value = $value; } - - public function getOperator(): string - { - return '$size'; - } } diff --git a/src/Builder/Query/TextOperator.php b/src/Builder/Query/TextOperator.php index f3028507f..7c1c0a7ba 100644 --- a/src/Builder/Query/TextOperator.php +++ b/src/Builder/Query/TextOperator.php @@ -22,6 +22,7 @@ final class TextOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$text'; public const PROPERTIES = [ 'search' => '$search', @@ -67,9 +68,4 @@ public function __construct( $this->caseSensitive = $caseSensitive; $this->diacriticSensitive = $diacriticSensitive; } - - public function getOperator(): string - { - return '$text'; - } } diff --git a/src/Builder/Query/TypeOperator.php b/src/Builder/Query/TypeOperator.php index cdfb8ae38..e539ebfc8 100644 --- a/src/Builder/Query/TypeOperator.php +++ b/src/Builder/Query/TypeOperator.php @@ -24,6 +24,7 @@ final class TypeOperator implements FieldQueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$type'; public const PROPERTIES = ['type' => 'type']; /** @var list $type */ @@ -45,9 +46,4 @@ public function __construct(int|string ...$type) $this->type = $type; } - - public function getOperator(): string - { - return '$type'; - } } diff --git a/src/Builder/Query/WhereOperator.php b/src/Builder/Query/WhereOperator.php index 90e3590ad..e679f7347 100644 --- a/src/Builder/Query/WhereOperator.php +++ b/src/Builder/Query/WhereOperator.php @@ -24,6 +24,7 @@ final class WhereOperator implements QueryInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$where'; public const PROPERTIES = ['function' => 'function']; /** @var Javascript|string $function */ @@ -40,9 +41,4 @@ public function __construct(Javascript|string $function) $this->function = $function; } - - public function getOperator(): string - { - return '$where'; - } } diff --git a/src/Builder/Stage/AddFieldsStage.php b/src/Builder/Stage/AddFieldsStage.php index 0ab28e268..7fedc8b2c 100644 --- a/src/Builder/Stage/AddFieldsStage.php +++ b/src/Builder/Stage/AddFieldsStage.php @@ -27,6 +27,7 @@ final class AddFieldsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$addFields'; 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. */ @@ -50,9 +51,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i $expression = (object) $expression; $this->expression = $expression; } - - public function getOperator(): string - { - return '$addFields'; - } } diff --git a/src/Builder/Stage/BucketAutoStage.php b/src/Builder/Stage/BucketAutoStage.php index 028ad9f29..2de5b3c20 100644 --- a/src/Builder/Stage/BucketAutoStage.php +++ b/src/Builder/Stage/BucketAutoStage.php @@ -27,6 +27,7 @@ final class BucketAutoStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$bucketAuto'; public const PROPERTIES = [ 'groupBy' => 'groupBy', @@ -72,9 +73,4 @@ public function __construct( $this->output = $output; $this->granularity = $granularity; } - - public function getOperator(): string - { - return '$bucketAuto'; - } } diff --git a/src/Builder/Stage/BucketStage.php b/src/Builder/Stage/BucketStage.php index d3423460f..211987c66 100644 --- a/src/Builder/Stage/BucketStage.php +++ b/src/Builder/Stage/BucketStage.php @@ -33,6 +33,7 @@ final class BucketStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$bucket'; public const PROPERTIES = [ 'groupBy' => 'groupBy', @@ -96,9 +97,4 @@ public function __construct( $this->default = $default; $this->output = $output; } - - public function getOperator(): string - { - return '$bucket'; - } } diff --git a/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php b/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php index ac4d37ef6..2539ddb19 100644 --- a/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php +++ b/src/Builder/Stage/ChangeStreamSplitLargeEventStage.php @@ -22,13 +22,9 @@ final class ChangeStreamSplitLargeEventStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$changeStreamSplitLargeEvent'; public function __construct() { } - - public function getOperator(): string - { - return '$changeStreamSplitLargeEvent'; - } } diff --git a/src/Builder/Stage/ChangeStreamStage.php b/src/Builder/Stage/ChangeStreamStage.php index c4925a3bb..d9c22eaa4 100644 --- a/src/Builder/Stage/ChangeStreamStage.php +++ b/src/Builder/Stage/ChangeStreamStage.php @@ -26,6 +26,7 @@ final class ChangeStreamStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$changeStream'; public const PROPERTIES = [ 'allChangesForCluster' => 'allChangesForCluster', @@ -88,9 +89,4 @@ public function __construct( $this->startAfter = $startAfter; $this->startAtOperationTime = $startAtOperationTime; } - - public function getOperator(): string - { - return '$changeStream'; - } } diff --git a/src/Builder/Stage/CollStatsStage.php b/src/Builder/Stage/CollStatsStage.php index 8fd74079f..d84245320 100644 --- a/src/Builder/Stage/CollStatsStage.php +++ b/src/Builder/Stage/CollStatsStage.php @@ -25,6 +25,7 @@ final class CollStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$collStats'; public const PROPERTIES = [ 'latencyStats' => 'latencyStats', @@ -62,9 +63,4 @@ public function __construct( $this->count = $count; $this->queryExecStats = $queryExecStats; } - - public function getOperator(): string - { - return '$collStats'; - } } diff --git a/src/Builder/Stage/CountStage.php b/src/Builder/Stage/CountStage.php index 316f0cceb..387da5efc 100644 --- a/src/Builder/Stage/CountStage.php +++ b/src/Builder/Stage/CountStage.php @@ -22,6 +22,7 @@ final class CountStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$count'; 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. */ @@ -34,9 +35,4 @@ public function __construct(string $field) { $this->field = $field; } - - public function getOperator(): string - { - return '$count'; - } } diff --git a/src/Builder/Stage/CurrentOpStage.php b/src/Builder/Stage/CurrentOpStage.php index 2a430ef29..3d0d6abb2 100644 --- a/src/Builder/Stage/CurrentOpStage.php +++ b/src/Builder/Stage/CurrentOpStage.php @@ -22,6 +22,7 @@ final class CurrentOpStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$currentOp'; public const PROPERTIES = [ 'allUsers' => 'allUsers', @@ -66,9 +67,4 @@ public function __construct( $this->idleSessions = $idleSessions; $this->localOps = $localOps; } - - public function getOperator(): string - { - return '$currentOp'; - } } diff --git a/src/Builder/Stage/DensifyStage.php b/src/Builder/Stage/DensifyStage.php index 9626c5fca..9ecff7bbc 100644 --- a/src/Builder/Stage/DensifyStage.php +++ b/src/Builder/Stage/DensifyStage.php @@ -31,6 +31,7 @@ final class DensifyStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$densify'; public const PROPERTIES = ['field' => 'field', 'range' => 'range', 'partitionByFields' => 'partitionByFields']; /** @@ -66,9 +67,4 @@ public function __construct( $this->partitionByFields = $partitionByFields; } - - public function getOperator(): string - { - return '$densify'; - } } diff --git a/src/Builder/Stage/DocumentsStage.php b/src/Builder/Stage/DocumentsStage.php index 6c68ae9df..d49585ef7 100644 --- a/src/Builder/Stage/DocumentsStage.php +++ b/src/Builder/Stage/DocumentsStage.php @@ -28,6 +28,7 @@ final class DocumentsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$documents'; public const PROPERTIES = ['documents' => 'documents']; /** @@ -54,9 +55,4 @@ public function __construct(PackedArray|ResolvesToArray|BSONArray|array $documen $this->documents = $documents; } - - public function getOperator(): string - { - return '$documents'; - } } diff --git a/src/Builder/Stage/FacetStage.php b/src/Builder/Stage/FacetStage.php index 344401892..6dc36bebd 100644 --- a/src/Builder/Stage/FacetStage.php +++ b/src/Builder/Stage/FacetStage.php @@ -28,6 +28,7 @@ final class FacetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$facet'; public const PROPERTIES = ['facet' => 'facet']; /** @var stdClass $facet */ @@ -51,9 +52,4 @@ public function __construct(PackedArray|Pipeline|BSONArray|array ...$facet) $facet = (object) $facet; $this->facet = $facet; } - - public function getOperator(): string - { - return '$facet'; - } } diff --git a/src/Builder/Stage/FillStage.php b/src/Builder/Stage/FillStage.php index 74eeae78c..f7b3b35e2 100644 --- a/src/Builder/Stage/FillStage.php +++ b/src/Builder/Stage/FillStage.php @@ -31,6 +31,7 @@ final class FillStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$fill'; public const PROPERTIES = [ 'output' => 'output', @@ -88,9 +89,4 @@ public function __construct( $this->partitionByFields = $partitionByFields; $this->sortBy = $sortBy; } - - public function getOperator(): string - { - return '$fill'; - } } diff --git a/src/Builder/Stage/GeoNearStage.php b/src/Builder/Stage/GeoNearStage.php index 342eedb1d..b2aa6588e 100644 --- a/src/Builder/Stage/GeoNearStage.php +++ b/src/Builder/Stage/GeoNearStage.php @@ -32,6 +32,7 @@ final class GeoNearStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$geoNear'; public const PROPERTIES = [ 'distanceField' => 'distanceField', @@ -128,9 +129,4 @@ public function __construct( $this->query = $query; $this->spherical = $spherical; } - - public function getOperator(): string - { - return '$geoNear'; - } } diff --git a/src/Builder/Stage/GraphLookupStage.php b/src/Builder/Stage/GraphLookupStage.php index 52c2d322f..936b59861 100644 --- a/src/Builder/Stage/GraphLookupStage.php +++ b/src/Builder/Stage/GraphLookupStage.php @@ -33,6 +33,7 @@ final class GraphLookupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$graphLookup'; public const PROPERTIES = [ 'from' => 'from', @@ -110,9 +111,4 @@ public function __construct( $this->restrictSearchWithMatch = $restrictSearchWithMatch; } - - public function getOperator(): string - { - return '$graphLookup'; - } } diff --git a/src/Builder/Stage/GroupStage.php b/src/Builder/Stage/GroupStage.php index 8f852a47d..b44cbc764 100644 --- a/src/Builder/Stage/GroupStage.php +++ b/src/Builder/Stage/GroupStage.php @@ -30,6 +30,7 @@ final class GroupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$group'; 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. */ @@ -56,9 +57,4 @@ public function __construct( $field = (object) $field; $this->field = $field; } - - public function getOperator(): string - { - return '$group'; - } } diff --git a/src/Builder/Stage/IndexStatsStage.php b/src/Builder/Stage/IndexStatsStage.php index 752ced1cd..0baaf8a18 100644 --- a/src/Builder/Stage/IndexStatsStage.php +++ b/src/Builder/Stage/IndexStatsStage.php @@ -21,13 +21,9 @@ final class IndexStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$indexStats'; public function __construct() { } - - public function getOperator(): string - { - return '$indexStats'; - } } diff --git a/src/Builder/Stage/LimitStage.php b/src/Builder/Stage/LimitStage.php index b5f69f76a..ec765fa8a 100644 --- a/src/Builder/Stage/LimitStage.php +++ b/src/Builder/Stage/LimitStage.php @@ -21,6 +21,7 @@ final class LimitStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$limit'; public const PROPERTIES = ['limit' => 'limit']; /** @var int $limit */ @@ -33,9 +34,4 @@ public function __construct(int $limit) { $this->limit = $limit; } - - public function getOperator(): string - { - return '$limit'; - } } diff --git a/src/Builder/Stage/ListLocalSessionsStage.php b/src/Builder/Stage/ListLocalSessionsStage.php index 4e7ee9d34..f438b0148 100644 --- a/src/Builder/Stage/ListLocalSessionsStage.php +++ b/src/Builder/Stage/ListLocalSessionsStage.php @@ -28,6 +28,7 @@ final class ListLocalSessionsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$listLocalSessions'; 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. */ @@ -51,9 +52,4 @@ public function __construct( $this->users = $users; $this->allUsers = $allUsers; } - - public function getOperator(): string - { - return '$listLocalSessions'; - } } diff --git a/src/Builder/Stage/ListSampledQueriesStage.php b/src/Builder/Stage/ListSampledQueriesStage.php index dc8ec2aa8..afa242591 100644 --- a/src/Builder/Stage/ListSampledQueriesStage.php +++ b/src/Builder/Stage/ListSampledQueriesStage.php @@ -22,6 +22,7 @@ final class ListSampledQueriesStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$listSampledQueries'; public const PROPERTIES = ['namespace' => 'namespace']; /** @var Optional|string $namespace */ @@ -34,9 +35,4 @@ public function __construct(Optional|string $namespace = Optional::Undefined) { $this->namespace = $namespace; } - - public function getOperator(): string - { - return '$listSampledQueries'; - } } diff --git a/src/Builder/Stage/ListSearchIndexesStage.php b/src/Builder/Stage/ListSearchIndexesStage.php index e6c48bdfb..c6643ad33 100644 --- a/src/Builder/Stage/ListSearchIndexesStage.php +++ b/src/Builder/Stage/ListSearchIndexesStage.php @@ -22,6 +22,7 @@ final class ListSearchIndexesStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$listSearchIndexes'; public const PROPERTIES = ['id' => 'id', 'name' => 'name']; /** @var Optional|string $id The id of the index to return information about. */ @@ -41,9 +42,4 @@ public function __construct( $this->id = $id; $this->name = $name; } - - public function getOperator(): string - { - return '$listSearchIndexes'; - } } diff --git a/src/Builder/Stage/ListSessionsStage.php b/src/Builder/Stage/ListSessionsStage.php index c242e0166..687425ce1 100644 --- a/src/Builder/Stage/ListSessionsStage.php +++ b/src/Builder/Stage/ListSessionsStage.php @@ -28,6 +28,7 @@ final class ListSessionsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$listSessions'; 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. */ @@ -51,9 +52,4 @@ public function __construct( $this->users = $users; $this->allUsers = $allUsers; } - - public function getOperator(): string - { - return '$listSessions'; - } } diff --git a/src/Builder/Stage/LookupStage.php b/src/Builder/Stage/LookupStage.php index 85226c2b6..a9bf0d7ee 100644 --- a/src/Builder/Stage/LookupStage.php +++ b/src/Builder/Stage/LookupStage.php @@ -32,6 +32,7 @@ final class LookupStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$lookup'; public const PROPERTIES = [ 'as' => 'as', @@ -99,9 +100,4 @@ public function __construct( $this->pipeline = $pipeline; } - - public function getOperator(): string - { - return '$lookup'; - } } diff --git a/src/Builder/Stage/MatchStage.php b/src/Builder/Stage/MatchStage.php index 85273f057..0c88db2cf 100644 --- a/src/Builder/Stage/MatchStage.php +++ b/src/Builder/Stage/MatchStage.php @@ -25,6 +25,7 @@ final class MatchStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$match'; public const PROPERTIES = ['query' => 'query']; /** @var QueryInterface|array $query */ @@ -41,9 +42,4 @@ public function __construct(QueryInterface|array $query) $this->query = $query; } - - public function getOperator(): string - { - return '$match'; - } } diff --git a/src/Builder/Stage/MergeStage.php b/src/Builder/Stage/MergeStage.php index a1994ff13..2fc3e94da 100644 --- a/src/Builder/Stage/MergeStage.php +++ b/src/Builder/Stage/MergeStage.php @@ -33,6 +33,7 @@ final class MergeStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$merge'; public const PROPERTIES = [ 'into' => 'into', @@ -85,9 +86,4 @@ public function __construct( $this->whenMatched = $whenMatched; $this->whenNotMatched = $whenNotMatched; } - - public function getOperator(): string - { - return '$merge'; - } } diff --git a/src/Builder/Stage/OutStage.php b/src/Builder/Stage/OutStage.php index e155d060f..77959edc8 100644 --- a/src/Builder/Stage/OutStage.php +++ b/src/Builder/Stage/OutStage.php @@ -24,6 +24,7 @@ final class OutStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$out'; public const PROPERTIES = ['coll' => 'coll']; /** @var Document|Serializable|array|stdClass|string $coll Target database name to write documents from $out to. */ @@ -36,9 +37,4 @@ public function __construct(Document|Serializable|stdClass|array|string $coll) { $this->coll = $coll; } - - public function getOperator(): string - { - return '$out'; - } } diff --git a/src/Builder/Stage/PlanCacheStatsStage.php b/src/Builder/Stage/PlanCacheStatsStage.php index 315b17327..5cfd75674 100644 --- a/src/Builder/Stage/PlanCacheStatsStage.php +++ b/src/Builder/Stage/PlanCacheStatsStage.php @@ -21,13 +21,9 @@ final class PlanCacheStatsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$planCacheStats'; public function __construct() { } - - public function getOperator(): string - { - return '$planCacheStats'; - } } diff --git a/src/Builder/Stage/ProjectStage.php b/src/Builder/Stage/ProjectStage.php index a836114aa..4b1c0f350 100644 --- a/src/Builder/Stage/ProjectStage.php +++ b/src/Builder/Stage/ProjectStage.php @@ -27,6 +27,7 @@ final class ProjectStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$project'; public const PROPERTIES = ['specification' => 'specification']; /** @var stdClass $specification */ @@ -50,9 +51,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i $specification = (object) $specification; $this->specification = $specification; } - - public function getOperator(): string - { - return '$project'; - } } diff --git a/src/Builder/Stage/RedactStage.php b/src/Builder/Stage/RedactStage.php index 6c56828b8..a1db25265 100644 --- a/src/Builder/Stage/RedactStage.php +++ b/src/Builder/Stage/RedactStage.php @@ -24,6 +24,7 @@ final class RedactStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$redact'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$redact'; - } } diff --git a/src/Builder/Stage/ReplaceRootStage.php b/src/Builder/Stage/ReplaceRootStage.php index 8e9fe719c..f88bf07b2 100644 --- a/src/Builder/Stage/ReplaceRootStage.php +++ b/src/Builder/Stage/ReplaceRootStage.php @@ -25,6 +25,7 @@ final class ReplaceRootStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$replaceRoot'; public const PROPERTIES = ['newRoot' => 'newRoot']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $newRoot */ @@ -37,9 +38,4 @@ public function __construct(Document|Serializable|ResolvesToObject|stdClass|arra { $this->newRoot = $newRoot; } - - public function getOperator(): string - { - return '$replaceRoot'; - } } diff --git a/src/Builder/Stage/ReplaceWithStage.php b/src/Builder/Stage/ReplaceWithStage.php index d320af933..84d6ffda4 100644 --- a/src/Builder/Stage/ReplaceWithStage.php +++ b/src/Builder/Stage/ReplaceWithStage.php @@ -26,6 +26,7 @@ final class ReplaceWithStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$replaceWith'; public const PROPERTIES = ['expression' => 'expression']; /** @var Document|ResolvesToObject|Serializable|array|stdClass $expression */ @@ -38,9 +39,4 @@ public function __construct(Document|Serializable|ResolvesToObject|stdClass|arra { $this->expression = $expression; } - - public function getOperator(): string - { - return '$replaceWith'; - } } diff --git a/src/Builder/Stage/SampleStage.php b/src/Builder/Stage/SampleStage.php index fd0cb4ed4..c00b2bb26 100644 --- a/src/Builder/Stage/SampleStage.php +++ b/src/Builder/Stage/SampleStage.php @@ -21,6 +21,7 @@ final class SampleStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$sample'; public const PROPERTIES = ['size' => 'size']; /** @var int $size The number of documents to randomly select. */ @@ -33,9 +34,4 @@ public function __construct(int $size) { $this->size = $size; } - - public function getOperator(): string - { - return '$sample'; - } } diff --git a/src/Builder/Stage/SearchMetaStage.php b/src/Builder/Stage/SearchMetaStage.php index 579cb4cb4..88f05bec1 100644 --- a/src/Builder/Stage/SearchMetaStage.php +++ b/src/Builder/Stage/SearchMetaStage.php @@ -25,6 +25,7 @@ final class SearchMetaStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$searchMeta'; public const PROPERTIES = ['meta' => 'meta']; /** @var Document|Serializable|array|stdClass $meta */ @@ -37,9 +38,4 @@ public function __construct(Document|Serializable|stdClass|array $meta) { $this->meta = $meta; } - - public function getOperator(): string - { - return '$searchMeta'; - } } diff --git a/src/Builder/Stage/SearchStage.php b/src/Builder/Stage/SearchStage.php index 60bdceb4f..188a2ece4 100644 --- a/src/Builder/Stage/SearchStage.php +++ b/src/Builder/Stage/SearchStage.php @@ -25,6 +25,7 @@ final class SearchStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$search'; public const PROPERTIES = ['search' => 'search']; /** @var Document|Serializable|array|stdClass $search */ @@ -37,9 +38,4 @@ public function __construct(Document|Serializable|stdClass|array $search) { $this->search = $search; } - - public function getOperator(): string - { - return '$search'; - } } diff --git a/src/Builder/Stage/SetStage.php b/src/Builder/Stage/SetStage.php index 534955887..45c545474 100644 --- a/src/Builder/Stage/SetStage.php +++ b/src/Builder/Stage/SetStage.php @@ -28,6 +28,7 @@ final class SetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$set'; public const PROPERTIES = ['field' => 'field']; /** @var stdClass $field */ @@ -51,9 +52,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i $field = (object) $field; $this->field = $field; } - - public function getOperator(): string - { - return '$set'; - } } diff --git a/src/Builder/Stage/SetWindowFieldsStage.php b/src/Builder/Stage/SetWindowFieldsStage.php index 9e5d43d46..ba8d63edf 100644 --- a/src/Builder/Stage/SetWindowFieldsStage.php +++ b/src/Builder/Stage/SetWindowFieldsStage.php @@ -28,6 +28,7 @@ final class SetWindowFieldsStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$setWindowFields'; 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. */ @@ -57,9 +58,4 @@ public function __construct( $this->output = $output; $this->partitionBy = $partitionBy; } - - public function getOperator(): string - { - return '$setWindowFields'; - } } diff --git a/src/Builder/Stage/ShardedDataDistributionStage.php b/src/Builder/Stage/ShardedDataDistributionStage.php index ebfaa912e..fe07d282a 100644 --- a/src/Builder/Stage/ShardedDataDistributionStage.php +++ b/src/Builder/Stage/ShardedDataDistributionStage.php @@ -22,13 +22,9 @@ final class ShardedDataDistributionStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$shardedDataDistribution'; public function __construct() { } - - public function getOperator(): string - { - return '$shardedDataDistribution'; - } } diff --git a/src/Builder/Stage/SkipStage.php b/src/Builder/Stage/SkipStage.php index 66d49e442..aab0242d8 100644 --- a/src/Builder/Stage/SkipStage.php +++ b/src/Builder/Stage/SkipStage.php @@ -21,6 +21,7 @@ final class SkipStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$skip'; public const PROPERTIES = ['skip' => 'skip']; /** @var int $skip */ @@ -33,9 +34,4 @@ public function __construct(int $skip) { $this->skip = $skip; } - - public function getOperator(): string - { - return '$skip'; - } } diff --git a/src/Builder/Stage/SortByCountStage.php b/src/Builder/Stage/SortByCountStage.php index 8121a900f..5e8f8821a 100644 --- a/src/Builder/Stage/SortByCountStage.php +++ b/src/Builder/Stage/SortByCountStage.php @@ -24,6 +24,7 @@ final class SortByCountStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sortByCount'; public const PROPERTIES = ['expression' => 'expression']; /** @var ExpressionInterface|Type|array|bool|float|int|null|stdClass|string $expression */ @@ -36,9 +37,4 @@ public function __construct(Type|ExpressionInterface|stdClass|array|bool|float|i { $this->expression = $expression; } - - public function getOperator(): string - { - return '$sortByCount'; - } } diff --git a/src/Builder/Stage/SortStage.php b/src/Builder/Stage/SortStage.php index 311de214b..f913d2897 100644 --- a/src/Builder/Stage/SortStage.php +++ b/src/Builder/Stage/SortStage.php @@ -28,6 +28,7 @@ final class SortStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$sort'; public const PROPERTIES = ['sort' => 'sort']; /** @var stdClass $sort */ @@ -51,9 +52,4 @@ public function __construct(Type|ExpressionInterface|Sort|stdClass|array|bool|fl $sort = (object) $sort; $this->sort = $sort; } - - public function getOperator(): string - { - return '$sort'; - } } diff --git a/src/Builder/Stage/UnionWithStage.php b/src/Builder/Stage/UnionWithStage.php index fe96c396b..25ced13de 100644 --- a/src/Builder/Stage/UnionWithStage.php +++ b/src/Builder/Stage/UnionWithStage.php @@ -30,6 +30,7 @@ final class UnionWithStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$unionWith'; 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. */ @@ -57,9 +58,4 @@ public function __construct( $this->pipeline = $pipeline; } - - public function getOperator(): string - { - return '$unionWith'; - } } diff --git a/src/Builder/Stage/UnsetStage.php b/src/Builder/Stage/UnsetStage.php index d84abc2c4..43575d8d5 100644 --- a/src/Builder/Stage/UnsetStage.php +++ b/src/Builder/Stage/UnsetStage.php @@ -26,6 +26,7 @@ final class UnsetStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Single; + public const NAME = '$unset'; public const PROPERTIES = ['field' => 'field']; /** @var list $field */ @@ -47,9 +48,4 @@ public function __construct(FieldPath|string ...$field) $this->field = $field; } - - public function getOperator(): string - { - return '$unset'; - } } diff --git a/src/Builder/Stage/UnwindStage.php b/src/Builder/Stage/UnwindStage.php index c9a436891..9959f462b 100644 --- a/src/Builder/Stage/UnwindStage.php +++ b/src/Builder/Stage/UnwindStage.php @@ -23,6 +23,7 @@ final class UnwindStage implements StageInterface, OperatorInterface { public const ENCODE = Encode::Object; + public const NAME = '$unwind'; public const PROPERTIES = [ 'path' => 'path', @@ -59,9 +60,4 @@ public function __construct( $this->includeArrayIndex = $includeArrayIndex; $this->preserveNullAndEmptyArrays = $preserveNullAndEmptyArrays; } - - public function getOperator(): string - { - return '$unwind'; - } } diff --git a/src/Builder/Type/CombinedFieldQuery.php b/src/Builder/Type/CombinedFieldQuery.php index 1693c2811..59f5a8554 100644 --- a/src/Builder/Type/CombinedFieldQuery.php +++ b/src/Builder/Type/CombinedFieldQuery.php @@ -59,6 +59,7 @@ static function (array $fieldQueries, QueryInterface|FieldQueryInterface|Type|st ); // Validate FieldQuery types and non-duplicate operators + /** @var array $seenOperators */ $seenOperators = []; foreach ($this->fieldQueries as $fieldQuery) { if ($fieldQuery instanceof stdClass) { @@ -66,7 +67,7 @@ static function (array $fieldQueries, QueryInterface|FieldQueryInterface|Type|st } if ($fieldQuery instanceof FieldQueryInterface && $fieldQuery instanceof OperatorInterface) { - $operator = $fieldQuery->getOperator(); + $operator = $fieldQuery::NAME; } elseif (is_array($fieldQuery)) { if (count($fieldQuery) !== 1) { throw new InvalidArgumentException(sprintf('Operator must contain exactly one key, %d given', count($fieldQuery))); diff --git a/src/Builder/Type/Encode.php b/src/Builder/Type/Encode.php index 792f07e83..d03491623 100644 --- a/src/Builder/Type/Encode.php +++ b/src/Builder/Type/Encode.php @@ -24,11 +24,6 @@ enum Encode */ case Object; - /** - * Same as Object, but only parameters are returned. The operator name will not be used. - */ - case FlatObject; - /** * Get the single parameter value */ diff --git a/src/Builder/Type/OperatorInterface.php b/src/Builder/Type/OperatorInterface.php index 52b1aaa9b..43d9f3f84 100644 --- a/src/Builder/Type/OperatorInterface.php +++ b/src/Builder/Type/OperatorInterface.php @@ -15,5 +15,6 @@ interface OperatorInterface /** @var array */ public const PROPERTIES = []; - public function getOperator(): string; + /** @var string|null */ + public const NAME = null; } diff --git a/src/Builder/Type/QueryObject.php b/src/Builder/Type/QueryObject.php index e07877f3f..d2298837a 100644 --- a/src/Builder/Type/QueryObject.php +++ b/src/Builder/Type/QueryObject.php @@ -56,11 +56,11 @@ private function __construct(array $queriesOrArrayOfQueries) foreach ($queriesOrArrayOfQueries as $fieldPath => $query) { if ($query instanceof QueryInterface) { if ($query instanceof OperatorInterface) { - if (isset($seenQueryOperators[$query->getOperator()])) { - throw new InvalidArgumentException(sprintf('Query operator "%s" cannot be used multiple times in the same query.', $query->getOperator())); + if (isset($seenQueryOperators[$query::NAME])) { + throw new InvalidArgumentException(sprintf('Query operator "%s" cannot be used multiple times in the same query.', $query::NAME)); } - $seenQueryOperators[$query->getOperator()] = true; + $seenQueryOperators[$query::NAME] = true; } $queries[] = $query; From c386f6da67f6a4d3ec975274f57bd1210bccd04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 4 Dec 2024 11:07:07 +0100 Subject: [PATCH 5/5] PHPLIB-1596 Fully describe `$search`, `$searchMeta` and `$vectorSearch` stages (#1537) --- .gitattributes | 1 + generator/README.md | 2 + generator/composer.json | 2 +- generator/config/definitions.php | 12 + generator/config/expressions.php | 12 + generator/config/schema.json | 9 +- generator/config/search/autocomplete.yaml | 152 + generator/config/search/compound.yaml | 156 + generator/config/search/embeddedDocument.yaml | 155 + generator/config/search/equals.yaml | 104 + generator/config/search/exists.yaml | 56 + generator/config/search/facet.yaml | 56 + generator/config/search/geoShape.yaml | 123 + generator/config/search/geoWithin.yaml | 103 + generator/config/search/in.yaml | 89 + generator/config/search/moreLikeThis.yaml | 99 + generator/config/search/near.yaml | 124 + generator/config/search/phrase.yaml | 109 + generator/config/search/queryString.yaml | 35 + generator/config/search/range.yaml | 139 + generator/config/search/regex.yaml | 42 + generator/config/search/text.yaml | 194 ++ generator/config/search/wildcard.yaml | 60 + generator/config/stage/search.yaml | 83 +- generator/config/stage/searchMeta.yaml | 110 +- generator/config/stage/vectorSearch.yaml | 119 + generator/js2yaml.html | 16 + generator/src/OperatorTestGenerator.php | 5 + phpcs.xml.dist | 2 +- psalm-baseline.xml | 5 + src/Builder/Search.php | 10 + src/Builder/Search/AutocompleteOperator.php | 76 + src/Builder/Search/CompoundOperator.php | 84 + .../Search/EmbeddedDocumentOperator.php | 57 + src/Builder/Search/EqualsOperator.php | 59 + src/Builder/Search/ExistsOperator.php | 48 + src/Builder/Search/FacetOperator.php | 49 + src/Builder/Search/FactoryTrait.php | 345 ++ src/Builder/Search/GeoShapeOperator.php | 62 + src/Builder/Search/GeoWithinOperator.php | 76 + src/Builder/Search/InOperator.php | 65 + src/Builder/Search/MoreLikeThisOperator.php | 52 + src/Builder/Search/NearOperator.php | 64 + src/Builder/Search/PhraseOperator.php | 83 + src/Builder/Search/QueryStringOperator.php | 40 + src/Builder/Search/RangeOperator.php | 85 + src/Builder/Search/RegexOperator.php | 67 + src/Builder/Search/TextOperator.php | 81 + src/Builder/Search/WildcardOperator.php | 66 + src/Builder/Stage/FactoryTrait.php | 76 +- src/Builder/Stage/FluentFactoryTrait.php | 78 +- src/Builder/Stage/SearchMetaStage.php | 35 +- src/Builder/Stage/SearchStage.php | 102 +- src/Builder/Stage/VectorSearchStage.php | 104 + src/Builder/Type/Encode.php | 5 + src/Builder/Type/SearchOperatorInterface.php | 7 + .../Search/AutocompleteOperatorTest.php | 138 + tests/Builder/Search/CompoundOperatorTest.php | 157 + .../Search/EmbeddedDocumentOperatorTest.php | 167 + tests/Builder/Search/EqualsOperatorTest.php | 125 + tests/Builder/Search/ExistsOperatorTest.php | 67 + tests/Builder/Search/FacetOperatorTest.php | 61 + tests/Builder/Search/GeoShapeOperatorTest.php | 204 ++ .../Builder/Search/GeoWithinOperatorTest.php | 124 + tests/Builder/Search/InOperatorTest.php | 101 + .../Search/MoreLikeThisOperatorTest.php | 115 + tests/Builder/Search/NearOperatorTest.php | 128 + tests/Builder/Search/PhraseOperatorTest.php | 102 + tests/Builder/Search/Pipelines.php | 2814 +++++++++++++++++ .../Search/QueryStringOperatorTest.php | 31 + tests/Builder/Search/RangeOperatorTest.php | 122 + tests/Builder/Search/RegexOperatorTest.php | 34 + tests/Builder/Search/TextOperatorTest.php | 194 ++ tests/Builder/Search/WildcardOperatorTest.php | 54 + tests/Builder/Stage/Pipelines.php | 350 ++ tests/Builder/Stage/SearchMetaStageTest.php | 124 +- tests/Builder/Stage/SearchStageTest.php | 9 +- tests/Builder/Stage/VectorSearchStageTest.php | 85 + 78 files changed, 9301 insertions(+), 55 deletions(-) create mode 100644 generator/config/search/autocomplete.yaml create mode 100644 generator/config/search/compound.yaml create mode 100644 generator/config/search/embeddedDocument.yaml create mode 100644 generator/config/search/equals.yaml create mode 100644 generator/config/search/exists.yaml create mode 100644 generator/config/search/facet.yaml create mode 100644 generator/config/search/geoShape.yaml create mode 100644 generator/config/search/geoWithin.yaml create mode 100644 generator/config/search/in.yaml create mode 100644 generator/config/search/moreLikeThis.yaml create mode 100644 generator/config/search/near.yaml create mode 100644 generator/config/search/phrase.yaml create mode 100644 generator/config/search/queryString.yaml create mode 100644 generator/config/search/range.yaml create mode 100644 generator/config/search/regex.yaml create mode 100644 generator/config/search/text.yaml create mode 100644 generator/config/search/wildcard.yaml create mode 100644 generator/config/stage/vectorSearch.yaml create mode 100644 src/Builder/Search.php create mode 100644 src/Builder/Search/AutocompleteOperator.php create mode 100644 src/Builder/Search/CompoundOperator.php create mode 100644 src/Builder/Search/EmbeddedDocumentOperator.php create mode 100644 src/Builder/Search/EqualsOperator.php create mode 100644 src/Builder/Search/ExistsOperator.php create mode 100644 src/Builder/Search/FacetOperator.php create mode 100644 src/Builder/Search/FactoryTrait.php create mode 100644 src/Builder/Search/GeoShapeOperator.php create mode 100644 src/Builder/Search/GeoWithinOperator.php create mode 100644 src/Builder/Search/InOperator.php create mode 100644 src/Builder/Search/MoreLikeThisOperator.php create mode 100644 src/Builder/Search/NearOperator.php create mode 100644 src/Builder/Search/PhraseOperator.php create mode 100644 src/Builder/Search/QueryStringOperator.php create mode 100644 src/Builder/Search/RangeOperator.php create mode 100644 src/Builder/Search/RegexOperator.php create mode 100644 src/Builder/Search/TextOperator.php create mode 100644 src/Builder/Search/WildcardOperator.php create mode 100644 src/Builder/Stage/VectorSearchStage.php create mode 100644 src/Builder/Type/SearchOperatorInterface.php create mode 100644 tests/Builder/Search/AutocompleteOperatorTest.php create mode 100644 tests/Builder/Search/CompoundOperatorTest.php create mode 100644 tests/Builder/Search/EmbeddedDocumentOperatorTest.php create mode 100644 tests/Builder/Search/EqualsOperatorTest.php create mode 100644 tests/Builder/Search/ExistsOperatorTest.php create mode 100644 tests/Builder/Search/FacetOperatorTest.php create mode 100644 tests/Builder/Search/GeoShapeOperatorTest.php create mode 100644 tests/Builder/Search/GeoWithinOperatorTest.php create mode 100644 tests/Builder/Search/InOperatorTest.php create mode 100644 tests/Builder/Search/MoreLikeThisOperatorTest.php create mode 100644 tests/Builder/Search/NearOperatorTest.php create mode 100644 tests/Builder/Search/PhraseOperatorTest.php create mode 100644 tests/Builder/Search/Pipelines.php create mode 100644 tests/Builder/Search/QueryStringOperatorTest.php create mode 100644 tests/Builder/Search/RangeOperatorTest.php create mode 100644 tests/Builder/Search/RegexOperatorTest.php create mode 100644 tests/Builder/Search/TextOperatorTest.php create mode 100644 tests/Builder/Search/WildcardOperatorTest.php create mode 100644 tests/Builder/Stage/VectorSearchStageTest.php diff --git a/.gitattributes b/.gitattributes index 75618ae42..7309afd20 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,5 +22,6 @@ rector.php export-ignore /src/Builder/Accumulator/*.php linguist-generated=true /src/Builder/Expression/*.php linguist-generated=true /src/Builder/Query/*.php linguist-generated=true +/src/Builder/Search/*.php linguist-generated=true /src/Builder/Stage/*.php linguist-generated=true /tests/Builder/*/Pipelines.php linguist-generated=true diff --git a/generator/README.md b/generator/README.md index 3e18976f9..02a3be4ec 100644 --- a/generator/README.md +++ b/generator/README.md @@ -42,6 +42,8 @@ Each operator can contain a `tests` section with a list if pipelines. To represe | Int64 | `!bson_int64 '123456789'` | | Decimal128 | `!bson_decimal128 '0.9'` | | UTCDateTime | `!bson_utcdatetime 0` | +| ObjectId | `!bson_ObjectId '5a9427648b0beebeb69589a1` | | Binary | `!bson_binary 'IA=='` | +| Binary UUID | `!bson_uuid 'fac32260-b511-4c69-8485-a2be5b7dda9e'` | 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/composer.json b/generator/composer.json index 2deb4ae95..c4dedcfb7 100644 --- a/generator/composer.json +++ b/generator/composer.json @@ -4,7 +4,7 @@ "repositories": [ { "type": "path", - "url": "../", + "url": "..", "symlink": true } ], diff --git a/generator/config/definitions.php b/generator/config/definitions.php index a4f952d39..06d9b44ed 100644 --- a/generator/config/definitions.php +++ b/generator/config/definitions.php @@ -58,4 +58,16 @@ OperatorTestGenerator::class, ], ], + + // Search Operators + [ + 'configFiles' => __DIR__ . '/search', + 'namespace' => 'MongoDB\\Builder\\Search', + 'classNameSuffix' => 'Operator', + 'generators' => [ + OperatorClassGenerator::class, + OperatorFactoryGenerator::class, + OperatorTestGenerator::class, + ], + ], ]; diff --git a/generator/config/expressions.php b/generator/config/expressions.php index f731234b2..a2c649e8e 100644 --- a/generator/config/expressions.php +++ b/generator/config/expressions.php @@ -109,6 +109,10 @@ 'implements' => [ResolvesToAny::class], 'acceptedTypes' => ['string'], ], + 'searchOperator' => [ + 'returnType' => Type\SearchOperatorInterface::class, + 'acceptedTypes' => [Type\SearchOperatorInterface::class, ...$bsonTypes['object']], + ], 'geometry' => [ 'returnType' => Type\GeometryInterface::class, 'acceptedTypes' => [Type\GeometryInterface::class, ...$bsonTypes['object']], @@ -168,4 +172,12 @@ 'GeoPoint' => [ 'acceptedTypes' => [...$bsonTypes['object']], ], + + // Search + 'searchPath' => [ + 'acceptedTypes' => ['string', 'array'], + ], + 'searchScore' => [ + 'acceptedTypes' => [...$bsonTypes['object']], + ], ]; diff --git a/generator/config/schema.json b/generator/config/schema.json index 8e2f5f320..c92e6ddb7 100644 --- a/generator/config/schema.json +++ b/generator/config/schema.json @@ -46,7 +46,8 @@ "resolvesToInt", "resolvesToTimestamp", "resolvesToLong", - "resolvesToDecimal" + "resolvesToDecimal", + "searchOperator" ] } }, @@ -60,7 +61,8 @@ "enum": [ "array", "object", - "single" + "single", + "search" ] }, "description": { @@ -135,7 +137,8 @@ "resolvesToInt", "intFieldPath", "int", "resolvesToTimestamp", "timestampFieldPath", "timestamp", "resolvesToLong", "longFieldPath", "long", - "resolvesToDecimal", "decimalFieldPath", "decimal" + "resolvesToDecimal", "decimalFieldPath", "decimal", + "searchPath", "searchScore", "searchOperator" ] } }, diff --git a/generator/config/search/autocomplete.yaml b/generator/config/search/autocomplete.yaml new file mode 100644 index 000000000..a984b9a39 --- /dev/null +++ b/generator/config/search/autocomplete.yaml @@ -0,0 +1,152 @@ +# $schema: ../schema.json +name: autocomplete +link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/' +type: + - searchOperator +encode: object +description: | + The autocomplete operator performs a search for a word or phrase that + contains a sequence of characters from an incomplete input string. The + fields that you intend to query with the autocomplete operator must be + indexed with the autocomplete data type in the collection's index definition. +arguments: + - + name: path + type: + - searchPath + - + name: query + type: + - string + - + name: tokenOrder + optional: true + type: + - string # any|sequential + - + name: fuzzy + optional: true + type: + - object + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Basic' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#basic-example' + pipeline: + - + $search: + autocomplete: + query: 'off' + path: 'title' + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + + - + name: 'Fuzzy' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#fuzzy-example' + pipeline: + - + $search: + autocomplete: + query: 'pre' + path: 'title' + fuzzy: + maxEdits: 1 + prefixLength: 1 + maxExpansions: 256 + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + + - + name: 'Token Order any' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-any-example' + pipeline: + - + $search: + autocomplete: + query: 'men with' + path: 'title' + tokenOrder: 'any' + - + $limit: 4 + - + $project: + _id: 0 + title: 1 + + - + name: 'Token Order sequential' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#simple-sequential-example' + pipeline: + - + $search: + autocomplete: + query: 'men with' + path: 'title' + tokenOrder: 'sequential' + - + $limit: 4 + - + $project: + _id: 0 + title: 1 + + - + name: 'Highlighting' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#highlighting-example' + pipeline: + - + $search: + autocomplete: + query: 'ger' + path: 'title' + highlight: + path: 'title' + - + $limit: 5 + - + $project: + score: + $meta: 'searchScore' + _id: 0 + title: 1 + highlights: + $meta: 'searchHighlights' + + - + name: 'Across Multiple Fields' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#search-across-multiple-fields' + pipeline: + - + $search: + compound: + should: + - + autocomplete: + query: 'inter' + path: 'title' + - + autocomplete: + query: 'inter' + path: 'plot' + minimumShouldMatch: 1 + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + plot: 1 diff --git a/generator/config/search/compound.yaml b/generator/config/search/compound.yaml new file mode 100644 index 000000000..7a1d9f419 --- /dev/null +++ b/generator/config/search/compound.yaml @@ -0,0 +1,156 @@ +# $schema: ../schema.json +name: compound +link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/' +type: + - searchOperator +encode: object +description: | + The compound operator combines two or more operators into a single query. + Each element of a compound query is called a clause, and each clause + consists of one or more sub-queries. +arguments: + - + name: must + optional: true + type: + - searchOperator + - array # of searchOperator + - + name: mustNot + optional: true + type: + - searchOperator + - array # of searchOperator + - + name: should + optional: true + type: + - searchOperator + - array # of searchOperator + - + name: filter + optional: true + type: + - searchOperator + - array # of searchOperator + - + name: minimumShouldMatch + optional: true + type: + - int + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'must and mustNot' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-mustnot-example' + pipeline: + - + $search: + compound: + must: + - + text: + query: 'varieties' + path: 'description' + mustNot: + - + text: + query: 'apples' + path: 'description' + + - + name: 'must and should' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#must-and-should-example' + pipeline: + - + $search: + compound: + must: + - + text: + query: 'varieties' + path: 'description' + should: + - + text: + query: 'Fuji' + path: 'description' + - + $project: + score: + $meta: 'searchScore' + + - + name: 'minimumShouldMatch' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#minimumshouldmatch-example' + pipeline: + - + $search: + compound: + must: + - + text: + query: 'varieties' + path: 'description' + should: + - + text: + query: 'Fuji' + path: 'description' + - + text: + query: 'Golden Delicious' + path: 'description' + minimumShouldMatch: 1 + + - + name: 'Filter' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#filter-examples' + pipeline: + - + $search: + compound: + must: + - + text: + query: 'varieties' + path: 'description' + should: + - + text: + query: 'banana' + path: 'description' + filter: + - + text: + query: 'granny' + path: 'description' + + - + name: 'Nested' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/#nested-example' + pipeline: + - + $search: + compound: + should: + - + text: + query: 'apple' + path: 'type' + - + compound: + must: + - + text: + query: 'organic' + path: 'category' + - + equals: + value: true + path: 'in_stock' + minimumShouldMatch: 1 diff --git a/generator/config/search/embeddedDocument.yaml b/generator/config/search/embeddedDocument.yaml new file mode 100644 index 000000000..19c804625 --- /dev/null +++ b/generator/config/search/embeddedDocument.yaml @@ -0,0 +1,155 @@ +# $schema: ../schema.json +name: embeddedDocument +link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/' +type: + - searchOperator +encode: object +description: | + The embeddedDocument operator is similar to $elemMatch operator. + It constrains multiple query predicates to be satisfied from a single + element of an array of embedded documents. embeddedDocument can be used only + for queries over fields of the embeddedDocuments +arguments: + - + name: path + type: + - searchPath + - + name: operator + type: + - searchOperator + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Basic' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#index-definition' + pipeline: + - + $search: + embeddedDocument: + path: 'items' + operator: + compound: + must: + - + text: + path: 'items.tags' + query: 'school' + should: + - + text: + path: 'items.name' + query: 'backpack' + score: + embedded: + aggregate: 'mean' + - + $limit: 5 + - + $project: + _id: 0 + items.name: 1 + items.tags: 1 + score: + $meta: 'searchScore' + + - + name: 'Facet' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#facet-query' + pipeline: + - + $searchMeta: + facet: + operator: + embeddedDocument: + path: 'items' + operator: + compound: + must: + - + text: + path: 'items.tags' + query: 'school' + should: + - + text: + path: 'items.name' + query: 'backpack' + facets: + purchaseMethodFacet: + type: 'string' + path: 'purchaseMethod' + + - + name: 'Query and Sort' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-and-sort' + pipeline: + - + $search: + embeddedDocument: + path: 'items' + operator: + text: + path: 'items.name' + query: 'laptop' + sort: + items.tags: 1 + - + $limit: 5 + - + $project: + _id: 0 + items.name: 1 + items.tags: 1 + score: + $meta: 'searchScore' + + - + name: 'Query for Matching Embedded Documents Only' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/#query-for-matching-embedded-documents-only' + pipeline: + - + $search: + embeddedDocument: + path: 'items' + operator: + compound: + must: + - + range: + path: 'items.quantity' + gt: 2 + - + exists: + path: 'items.price' + - + text: + path: 'items.tags' + query: 'school' + - + $limit: 2 + - + $project: + _id: 0 + storeLocation: 1 + items: + $filter: + input: '$items' + cond: + $and: + - + $ifNull: + - '$$this.price' + - 'false' + - + $gt: + - '$$this.quantity' + - 2 + - + $in: + - 'office' + - '$$this.tags' diff --git a/generator/config/search/equals.yaml b/generator/config/search/equals.yaml new file mode 100644 index 000000000..b3e50c641 --- /dev/null +++ b/generator/config/search/equals.yaml @@ -0,0 +1,104 @@ +# $schema: ../schema.json +name: equals +link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/' +type: + - searchOperator +encode: object +description: | + The equals operator checks whether a field matches a value you specify. +arguments: + - + name: path + type: + - searchPath + - + name: value + type: + - binData + - bool + - date + - objectId + - 'null' + - number + - string + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Boolean' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#boolean-examples' + pipeline: + - + $search: + equals: + path: 'verified_user' + value: true + - + $project: + name: 1 + _id: 0 + score: + $meta: 'searchScore' + + - + name: 'ObjectId' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#objectid-example' + pipeline: + - + $search: + equals: + path: 'teammates' + value: !bson_objectId '5a9427648b0beebeb69589a1' + + - + name: 'Date' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#date-example' + pipeline: + - + $search: + equals: + path: 'account_created' + value: !bson_utcdatetime '2022-05-04T05:01:08.000+00:00' + + - + name: 'Number' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#number-example' + pipeline: + - + $search: + equals: + path: 'employee_number' + value: 259 + + - + name: 'String' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#string-example' + pipeline: + - + $search: + equals: + path: 'name' + value: 'jim hall' + + - + name: 'UUID' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#uuid-example' + pipeline: + - + $search: + equals: + path: 'uuid' + value: !bson_uuid 'fac32260-b511-4c69-8485-a2be5b7dda9e' + + - + name: 'Null' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/#null-example' + pipeline: + - + $search: + equals: + path: 'job_title' + value: ~ diff --git a/generator/config/search/exists.yaml b/generator/config/search/exists.yaml new file mode 100644 index 000000000..062e8ba59 --- /dev/null +++ b/generator/config/search/exists.yaml @@ -0,0 +1,56 @@ +# $schema: ../schema.json +name: exists +link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/' +type: + - searchOperator +encode: object +description: | + The exists operator tests if a path to a specified indexed field name exists in a document. +arguments: + - + name: path + type: + - searchPath + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Basic' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#basic-example' + pipeline: + - + $search: + exists: + path: 'type' + + - + name: 'Embedded' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#embedded-example' + pipeline: + - + $search: + exists: + path: 'quantities.lemons' + + - + name: 'Compound' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/#compound-example' + pipeline: + - + $search: + compound: + must: + - + exists: + path: 'type' + - + text: + query: 'apple' + path: 'type' + should: + text: + query: 'fuji' + path: 'description' diff --git a/generator/config/search/facet.yaml b/generator/config/search/facet.yaml new file mode 100644 index 000000000..53dc8cba9 --- /dev/null +++ b/generator/config/search/facet.yaml @@ -0,0 +1,56 @@ +# $schema: ../schema.json +name: facet +link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/' +type: + - searchOperator # should be searchCollector +encode: object +description: | + The facet collector groups results by values or ranges in the specified + faceted fields and returns the count for each of those groups. +arguments: + - + name: facets + type: + - object # map of facetDefinition + - + name: operator + optional: true + type: + - searchOperator +tests: + - + name: 'Facet' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples' + pipeline: + - + $search: + facet: + operator: + near: + path: 'released' + origin: !bson_utcdatetime '1999-07-01T00:00:00.000+00:00' + pivot: 7776000000 + facets: + genresFacet: + type: 'string' + path: 'genres' + - + $limit: 2 + - + $facet: + docs: + - + $project: + title: 1 + released: 1 + meta: + - + $replaceWith: '$$SEARCH_META' + - + $limit: 1 + - + $set: + meta: + $arrayElemAt: + - '$meta' + - 0 diff --git a/generator/config/search/geoShape.yaml b/generator/config/search/geoShape.yaml new file mode 100644 index 000000000..4da121e45 --- /dev/null +++ b/generator/config/search/geoShape.yaml @@ -0,0 +1,123 @@ +# $schema: ../schema.json +name: geoShape +link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/' +type: + - searchOperator +encode: object +description: | + The geoShape operator supports querying shapes with a relation to a given + geometry if indexShapes is set to true in the index definition. +arguments: + - + name: path + type: + - searchPath + - + name: relation + type: + - string # contains | disjoint | intersects | within + - + name: geometry + type: + - geometry + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Disjoint' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#disjoint-example' + pipeline: + - + $search: + geoShape: + relation: 'disjoint' + geometry: + type: 'Polygon' + coordinates: + - + - [-161.323242, 22.512557] + - [-152.446289, 22.065278] + - [-156.09375, 17.811456] + - [-161.323242, 22.512557] + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: 'searchScore' + + - + name: 'Intersect' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#intersects-example' + pipeline: + - + $search: + geoShape: + relation: 'intersects' + geometry: + type: 'MultiPolygon' + coordinates: + - + - + - [2.16942, 41.40082] + - [2.17963, 41.40087] + - [2.18146, 41.39716] + - [2.15533, 41.40686] + - [2.14596, 41.38475] + - [2.17519, 41.41035] + - [2.16942, 41.40082] + - + - + - [2.16365, 41.39416] + - [2.16963, 41.39726] + - [2.15395, 41.38005] + - [2.17935, 41.43038] + - [2.16365, 41.39416] + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: 'searchScore' + + - + name: 'Within' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoShape/#within-example' + pipeline: + - + $search: + geoShape: + relation: 'within' + geometry: + type: 'Polygon' + coordinates: + - + - [-74.3994140625, 40.5305017757] + - [-74.7290039063, 40.5805846641] + - [-74.7729492188, 40.9467136651] + - [-74.0698242188, 41.1290213475] + - [-73.65234375, 40.9964840144] + - [-72.6416015625, 40.9467136651] + - [-72.3559570313, 40.7971774152] + - [-74.3994140625, 40.5305017757] + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: 'searchScore' diff --git a/generator/config/search/geoWithin.yaml b/generator/config/search/geoWithin.yaml new file mode 100644 index 000000000..1739f1997 --- /dev/null +++ b/generator/config/search/geoWithin.yaml @@ -0,0 +1,103 @@ +# $schema: ../schema.json +name: geoWithin +link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/' +type: + - searchOperator +encode: object +description: | + The geoWithin operator supports querying geographic points within a given + geometry. Only points are returned, even if indexShapes value is true in + the index definition. +arguments: + - + name: path + type: + - searchPath + - + name: box + optional: true + type: + - object + - + name: circle + optional: true + type: + - object + - + name: geometry + optional: true + type: + - geometry + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'box' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#box-example' + pipeline: + - + $search: + geoWithin: + path: 'address.location' + box: + bottomLeft: + type: 'Point' + coordinates: [112.467, -55.05] + topRight: + type: 'Point' + coordinates: [168, -9.133] + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 + + - + name: 'circle' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#circle-example' + pipeline: + - + $search: + geoWithin: + circle: + center: + type: 'Point' + coordinates: [-73.54, 45.54] + radius: 1600 + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 + + - + name: 'geometry' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/geoWithin/#geometry-examples' + pipeline: + - + $search: + geoWithin: + geometry: + type: 'Polygon' + coordinates: + - + - [-161.323242, 22.512557] + - [-152.446289, 22.065278] + - [-156.09375, 17.811456] + - [-161.323242, 22.512557] + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 diff --git a/generator/config/search/in.yaml b/generator/config/search/in.yaml new file mode 100644 index 000000000..cc1aa6c33 --- /dev/null +++ b/generator/config/search/in.yaml @@ -0,0 +1,89 @@ +# $schema: ../schema.json +name: in +link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/' +type: + - searchOperator +encode: object +description: | + The in operator performs a search for an array of BSON values in a field. +arguments: + - + name: path + type: + - searchPath + - + name: value + type: + - any + - array # of any + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Single Value Field Match' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' + pipeline: + - + $search: + in: + path: 'birthdate' + value: + - !bson_utcdatetime '1977-03-02T02:20:31.000+00:00' + - !bson_utcdatetime '1977-03-01T00:00:00.000+00:00' + - !bson_utcdatetime '1977-05-06T21:57:35.000+00:00' + - + $project: + _id: 0 + name: 1 + birthdate: 1 + + - + name: 'Array Value Field Match' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' + pipeline: + - + $search: + in: + path: 'accounts' + value: + - 371138 + - 371139 + - 371140 + - + $project: + _id: 0 + name: 1 + accounts: 1 + + - + name: 'Compound Query Match' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/in/#examples' + pipeline: + - + $search: + compound: + must: + - + in: + path: 'name' + value: + - 'james sanchez' + - 'jennifer lawrence' + should: + - + in: + path: '_id' + value: + - !bson_objectId '5ca4bbcea2dd94ee58162a72' + - !bson_objectId '5ca4bbcea2dd94ee58162a91' + - + $limit: 5 + - + $project: + _id: 1 + name: 1 + score: + $meta: 'searchScore' diff --git a/generator/config/search/moreLikeThis.yaml b/generator/config/search/moreLikeThis.yaml new file mode 100644 index 000000000..8c4803bdd --- /dev/null +++ b/generator/config/search/moreLikeThis.yaml @@ -0,0 +1,99 @@ +# $schema: ../schema.json +name: moreLikeThis +link: 'https://www.mongodb.com/docs/atlas/atlas-search/moreLikeThis/' +type: + - searchOperator +encode: object +description: | + The moreLikeThis operator returns documents similar to input documents. + The moreLikeThis operator allows you to build features for your applications + that display similar or alternative results based on one or more given documents. +arguments: + - + name: like + type: + - object + - array # of object + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Single Document with Multiple Fields' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-1--single-document-with-multiple-fields' + pipeline: + - + $search: + moreLikeThis: + like: + title: 'The Godfather' + genres: 'action' + - + $limit: 5 + - + $project: + _id: 0 + title: 1 + released: 1 + genres: 1 + + - + name: 'Input Document Excluded in Results' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-2--input-document-excluded-in-results' + pipeline: + - + $search: + compound: + must: + - + moreLikeThis: + like: + _id: !bson_objectId '573a1396f29313caabce4a9a' + genres: + - 'Crime' + - 'Drama' + title: 'The Godfather' + mustNot: + - + equals: + path: '_id' + value: !bson_objectId '573a1396f29313caabce4a9a' + - + $limit: 5 + - + $project: + _id: 1 + title: 1 + released: 1 + genres: 1 + + - + name: 'Multiple Analyzers' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/morelikethis/#example-3--multiple-analyzers' + pipeline: + - + $search: + compound: + should: + - + moreLikeThis: + like: + _id: !bson_objectId '573a1396f29313caabce4a9a' + genres: + - 'Crime' + - 'Drama' + title: 'The Godfather' + mustNot: + - + equals: + path: '_id' + value: !bson_objectId '573a1394f29313caabcde9ef' + - + $limit: 10 + - + $project: + title: 1 + genres: 1 + _id: 1 diff --git a/generator/config/search/near.yaml b/generator/config/search/near.yaml new file mode 100644 index 000000000..bd4119cf9 --- /dev/null +++ b/generator/config/search/near.yaml @@ -0,0 +1,124 @@ +# $schema: ../schema.json +name: near +link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/' +type: + - searchOperator +encode: object +description: | + The near operator supports querying and scoring numeric, date, and GeoJSON point values. +arguments: + - + name: path + type: + - searchPath + - + name: origin + type: + - date + - number + - geometry + - + name: pivot + type: + - number + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Number' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#number-example' + pipeline: + - + $search: + index: 'runtimes' + near: + path: 'runtime' + origin: 279 + pivot: 2 + - + $limit: 7 + - + $project: + _id: 0 + title: 1 + runtime: 1 + score: + $meta: 'searchScore' + + - + name: 'Date' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#date-example' + pipeline: + - + $search: + index: 'releaseddate' + near: + path: 'released' + origin: !bson_utcdatetime '1915-09-13T00:00:00.000+00:00' + pivot: 7776000000 + - + $limit: 3 + - + $project: + _id: 0 + title: 1 + released: 1 + score: + $meta: 'searchScore' + + - + name: 'GeoJSON Point' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#geojson-point-examples' + pipeline: + - + $search: + near: + origin: + type: 'Point' + coordinates: + - -8.61308 + - 41.1413 + pivot: 1000 + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + name: 1 + address: 1 + score: + $meta: 'searchScore' + + - + name: 'Compound' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/near/#compound-example' + pipeline: + - + $search: + compound: + must: + text: + query: 'Apartment' + path: 'property_type' + should: + near: + origin: + type: 'Point' + coordinates: + - 114.15027 + - 22.28158 + pivot: 1000 + path: 'address.location' + - + $limit: 3 + - + $project: + _id: 0 + property_type: 1 + address: 1 + score: + $meta: 'searchScore' diff --git a/generator/config/search/phrase.yaml b/generator/config/search/phrase.yaml new file mode 100644 index 000000000..4d9b75c4e --- /dev/null +++ b/generator/config/search/phrase.yaml @@ -0,0 +1,109 @@ +# $schema: ../schema.json +name: phrase +link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/' +type: + - searchOperator +encode: object +description: | + The phrase operator performs search for documents containing an ordered sequence of terms using the analyzer specified in the index configuration. +arguments: + - + name: path + type: + - searchPath + - + name: query + type: + - string + - array # of string + - + name: slop + optional: true + type: + - int + - + name: synonyms + optional: true + type: + - string + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Single Phrase' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#single-phrase-example' + pipeline: + - + $search: + phrase: + path: 'title' + query: 'new york' + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Multiple Phrase' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#multiple-phrases-example' + pipeline: + - + $search: + phrase: + path: 'title' + query: + - 'the man' + - 'the moon' + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Phrase Slop' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#slop-example' + pipeline: + - + $search: + phrase: + path: 'title' + query: 'men women' + slop: 5 + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Phrase Synonyms' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/phrase/#synonyms-example' + pipeline: + - + $search: + phrase: + path: 'plot' + query: 'automobile race' + slop: 5 + synonyms: 'my_synonyms' + - + $limit: 5 + - + $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: 'searchScore' diff --git a/generator/config/search/queryString.yaml b/generator/config/search/queryString.yaml new file mode 100644 index 000000000..8202771c9 --- /dev/null +++ b/generator/config/search/queryString.yaml @@ -0,0 +1,35 @@ +# $schema: ../schema.json +name: queryString +link: 'https://www.mongodb.com/docs/atlas/atlas-search/queryString/' +type: + - searchOperator +encode: object +description: | + +arguments: + - + name: defaultPath + type: + - searchPath + - + name: query + type: + - string + +# The various example from the doc are variations of the "query" parameter +# this is not pertinent for testing the aggregation builder, unless we create +# a queryString builder. +tests: + - + name: 'Boolean Operator Queries' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/queryString/#boolean-operator-queries' + pipeline: + - + $search: + queryString: + defaultPath: 'title' + query: 'Rocky AND (IV OR 4 OR Four)' + - + $project: + _id: 0 + title: 1 diff --git a/generator/config/search/range.yaml b/generator/config/search/range.yaml new file mode 100644 index 000000000..f42c69176 --- /dev/null +++ b/generator/config/search/range.yaml @@ -0,0 +1,139 @@ +# $schema: ../schema.json +name: range +link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/' +type: + - searchOperator +encode: object +description: | + The range operator supports querying and scoring numeric, date, and string values. + You can use this operator to find results that are within a given numeric, date, objectId, or letter (from the English alphabet) range. +arguments: + - + name: path + type: + - searchPath + - + name: gt + optional: true + type: + - date + - number + - string + - objectId + - + name: gte + optional: true + type: + - date + - number + - string + - objectId + - + name: lt + optional: true + type: + - date + - number + - string + - objectId + - + name: lte + optional: true + type: + - date + - number + - string + - objectId + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Number gte lte' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example' + pipeline: + - + $search: + range: + path: 'runtime' + gte: 2 + lte: 3 + - + $limit: 5 + - + $project: + _id: 0 + title: 1 + runtime: 1 + + - + name: 'Number lte' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#number-example' + pipeline: + - + $search: + range: + path: 'runtime' + lte: 2 + - + $limit: 5 + - + $project: + _id: 0 + title: 1 + runtime: 1 + score: + $meta: 'searchScore' + + - + name: 'Date' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#date-example' + pipeline: + - + $search: + range: + path: 'released' + gt: !bson_utcdatetime '2010-01-01T00:00:00.000Z' + lt: !bson_utcdatetime '2015-01-01T00:00:00.000Z' + - + $limit: 5 + - + $project: + _id: 0 + title: 1 + released: 1 + + - + name: 'ObjectId' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#objectid-example' + pipeline: + - + $search: + range: + path: '_id' + gte: !bson_objectId '573a1396f29313caabce4a9a' + lte: !bson_objectId '573a1396f29313caabce4ae7' + - + $project: + _id: 1 + title: 1 + released: 1 + + - + name: 'String' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/range/#string-example' + pipeline: + - + $search: + range: + path: 'title' + gt: 'city' + lt: 'country' + - + $limit: 5 + - + $project: + _id: 0 + title: 1 diff --git a/generator/config/search/regex.yaml b/generator/config/search/regex.yaml new file mode 100644 index 000000000..869ffabde --- /dev/null +++ b/generator/config/search/regex.yaml @@ -0,0 +1,42 @@ +# $schema: ../schema.json +name: regex +link: 'https://www.mongodb.com/docs/atlas/atlas-search/regex/' +type: + - searchOperator +encode: object +description: | + regex interprets the query field as a regular expression. + regex is a term-level operator, meaning that the query field isn't analyzed. +arguments: + - + name: path + type: + - searchPath + - + name: query + type: + - string + - + name: allowAnalyzedField + optional: true + type: + - bool + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Regex' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/regex/#examples' + pipeline: + - + $search: + regex: + path: 'title' + query: '[0-9]{2} (.){4}s' + - + $project: + _id: 0 + title: 1 diff --git a/generator/config/search/text.yaml b/generator/config/search/text.yaml new file mode 100644 index 000000000..dbd48cdd0 --- /dev/null +++ b/generator/config/search/text.yaml @@ -0,0 +1,194 @@ +# $schema: ../schema.json +name: text +link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/' +type: + - searchOperator +encode: object +description: | + The text operator performs a full-text search using the analyzer that you specify in the index configuration. + If you omit an analyzer, the text operator uses the default standard analyzer. +arguments: + - + name: path + type: + - searchPath + - + name: query + type: + - string + - + name: fuzzy + optional: true + type: + - object + - + name: matchCriteria + optional: true + type: + - string # "any" | "all" + - + name: synonyms + optional: true + type: + - string + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Basic' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#basic-example' + pipeline: + - + $search: + text: + path: 'title' + query: 'surfer' + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' + - + name: 'Fuzzy Default' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' + pipeline: + - + $search: + text: + path: 'title' + query: 'naw yark' + fuzzy: {} + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Fuzzy maxExpansions' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' + pipeline: + - + $search: + text: + path: 'title' + query: 'naw yark' + fuzzy: + maxEdits: 1 + maxExpansions: 100 + - + $limit: 10 + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Fuzzy prefixLength' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#fuzzy-examples' + pipeline: + - + $search: + text: + path: 'title' + query: 'naw yark' + fuzzy: + maxEdits: 1 + prefixLength: 2 + - + $limit: 8 + - + $project: + _id: 1 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Match any Using equivalent Mapping' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-equivalent-mapping' + pipeline: + - + $search: + text: + path: 'plot' + query: 'attire' + synonyms: 'my_synonyms' + matchCriteria: 'any' + - + $limit: 5 + - + $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Match any Using explicit Mapping' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#match-any-using-explicit-mapping' + pipeline: + - + $search: + text: + path: 'plot' + query: 'boat race' + synonyms: 'my_synonyms' + matchCriteria: 'any' + - + $limit: 10 + - + $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Match all Using Synonyms' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/#match-all-using-synonyms' + pipeline: + - + $search: + text: + path: 'plot' + query: 'automobile race' + matchCriteria: 'all' + synonyms: 'my_synonyms' + - + $limit: 20 + - + $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: 'searchScore' + + - + name: 'Wildcard Path' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/text/' + pipeline: + - + $search: + text: + path: + wildcard: '*' + query: 'surfer' + - + $project: + _id: 0 + title: 1 + score: + $meta: 'searchScore' diff --git a/generator/config/search/wildcard.yaml b/generator/config/search/wildcard.yaml new file mode 100644 index 000000000..d17fb4803 --- /dev/null +++ b/generator/config/search/wildcard.yaml @@ -0,0 +1,60 @@ +# $schema: ../schema.json +name: wildcard +link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/' +type: + - searchOperator +encode: object +description: | + The wildcard operator enables queries which use special characters in the search string that can match any character. +arguments: + - + name: path + type: + - searchPath + - + name: query + type: + - string + - + name: allowAnalyzedField + optional: true + type: + - bool + - + name: score + optional: true + type: + - searchScore +tests: + - + name: 'Wildcard Path' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#index-definition' + pipeline: + - + $search: + wildcard: + query: 'Wom?n *' + path: + wildcard: '*' + - + $limit: 5 + - + $project: + _id: 0 + title: 1 + + - + name: 'Escape Character Example' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/wildcard/#escape-character-example' + pipeline: + - + $search: + wildcard: + query: '*\?' + path: 'title' + - + $limit: 5 + - + $project: + _id: 0 + title: 1 diff --git a/generator/config/stage/search.yaml b/generator/config/stage/search.yaml index 2531e75f6..34bf57a34 100644 --- a/generator/config/stage/search.yaml +++ b/generator/config/stage/search.yaml @@ -3,16 +3,93 @@ name: $search link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/' type: - stage -encode: single +encode: object description: | Performs a full-text search of the field or fields in an Atlas collection. NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. arguments: - - name: search + name: operator + mergeObject: true + type: + - searchOperator + description: | + Operator to search with. You can provide a specific operator or use + the compound operator to run a compound query with multiple operators. + - + name: index + optional: true + type: + - string + description: | + Name of the Atlas Search index to use. If omitted, defaults to "default". + - + name: highlight + optional: true + type: + # @todo support "highlight" type object + # https://www.mongodb.com/docs/atlas/atlas-search/highlighting/ + - object + description: | + Specifies the highlighting options for displaying search terms in their original context. + - + name: concurrent + optional: true + type: + - bool + description: | + Parallelize search across segments on dedicated search nodes. + If you don't have separate search nodes on your cluster, + Atlas Search ignores this flag. If omitted, defaults to false. + - + name: count + optional: true + type: + - string + description: | + Document that specifies the count options for retrieving a count of the results. + - + name: searchAfter + optional: true + type: + - string + description: | + Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. + - + name: searchBefore + optional: true + type: + - string + description: | + Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. + - + name: scoreDetails + optional: true + type: + - bool + description: | + Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. + - + name: sort + optional: true + type: + - object + description: | + Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. + - + name: returnStoredSource + optional: true + type: + - bool + description: | + Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. + - + name: tracking + optional: true type: - object - + description: | + Document that specifies the tracking option to retrieve analytics information on the search terms. tests: - name: 'Example' diff --git a/generator/config/stage/searchMeta.yaml b/generator/config/stage/searchMeta.yaml index 322d048eb..a7d92c272 100644 --- a/generator/config/stage/searchMeta.yaml +++ b/generator/config/stage/searchMeta.yaml @@ -3,16 +3,34 @@ name: $searchMeta link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/' type: - stage -encode: single +encode: object description: | Returns different types of metadata result documents for the Atlas Search query against an Atlas collection. NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. arguments: - - name: meta + name: operator + mergeObject: true type: - - object + - searchOperator + description: | + Operator to search with. You can provide a specific operator or use + the compound operator to run a compound query with multiple operators. + - + name: index + optional: true + type: + - string + description: | + Name of the Atlas Search index to use. If omitted, defaults to default. + - + name: count + optional: true + type: + - object + description: | + Document that specifies the count options for retrieving a count of the results. tests: - name: 'Example' @@ -26,3 +44,89 @@ tests: lt: 1999 count: type: 'total' + + - + name: 'Year Facet' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-1' + pipeline: + - $searchMeta: + facet: + operator: + range: + path: 'year' + gte: 1980 + lte: 2000 + facets: + yearFacet: + type: 'number' + path: 'year' + boundaries: + - 1980 + - 1990 + - 2000 + default: 'other' + + - + name: 'Date Facet' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-2' + pipeline: + - + $searchMeta: + facet: + operator: + range: + path: 'released' + gte: !bson_utcdatetime '2000-01-01T00:00:00.000Z' + lte: !bson_utcdatetime '2015-01-31T00:00:00.000Z' + facets: + yearFacet: + type: 'date' + path: 'released' + boundaries: + - !bson_utcdatetime '2000-01-01' + - !bson_utcdatetime '2005-01-01' + - !bson_utcdatetime '2010-01-01' + - !bson_utcdatetime '2015-01-01' + default: 'other' + + - + name: 'Metadata Results' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples' + pipeline: + - + $searchMeta: + facet: + operator: + range: + path: 'released' + gte: !bson_utcdatetime '2000-01-01T00:00:00.000Z' + lte: !bson_utcdatetime '2015-01-31T00:00:00.000Z' + facets: + directorsFacet: + type: 'string' + path: 'directors' + numBuckets: 7 + yearFacet: + type: 'number' + path: 'year' + boundaries: + - 2000 + - 2005 + - 2010 + - 2015 + + - + name: 'Autocomplete Bucket Results through Facet Queries' + link: 'https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#bucket-results-through-facet-queries' + pipeline: + - + $searchMeta: + facet: + operator: + autocomplete: + path: 'title' + query: 'Gravity' + facets: + titleFacet: + type: 'string' + path: 'title' diff --git a/generator/config/stage/vectorSearch.yaml b/generator/config/stage/vectorSearch.yaml new file mode 100644 index 000000000..ec4b4ff4b --- /dev/null +++ b/generator/config/stage/vectorSearch.yaml @@ -0,0 +1,119 @@ +# $schema: ../schema.json +name: $vectorSearch +link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/' +type: + - stage +encode: object +description: | + The $vectorSearch stage performs an ANN or ENN search on a vector in the specified field. +arguments: + - + name: index + type: + - string + description: | + Name of the Atlas Vector Search index to use. + - + name: limit + type: + - int + description: | + Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. + - + name: path + type: + - searchPath + description: | + Indexed vector type field to search. + - + name: queryVector + type: + - array # of numbers + description: | + Array of numbers that represent the query vector. The number type must match the indexed field value type. + - + name: exact + optional: true + type: + - bool + description: | + This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. + - + name: filter + optional: true + type: + - query + description: | + Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. + - + name: numCandidates + optional: true + type: + - int + description: | + This field is required if exact is false or omitted. + Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). + +tests: + - + name: 'ANN Basic' + link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples' + pipeline: + - + $vectorSearch: + index: 'vector_index' + path: 'plot_embedding' + queryVector: [-0.0016261312, -0.028070757, -0.011342932] # skip other numbers, not relevant to the test + numCandidates: 150 + limit: 10 + - + $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: 'vectorSearchScore' + + - + name: 'ANN Filter' + link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples' + pipeline: + - + $vectorSearch: + index: 'vector_index' + path: 'plot_embedding' + filter: + $and: + - + year: + $lt: 1975 + queryVector: [0.02421053, -0.022372592, -0.006231137] # skip other numbers, not relevant to the test + numCandidates: 150 + limit: 10 + - + $project: + _id: 0 + title: 1 + plot: 1 + year: 1 + score: + $meta: 'vectorSearchScore' + + - + name: 'ENN' + link: 'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-examples' + pipeline: + - + $vectorSearch: + index: 'vector_index' + path: 'plot_embedding' + queryVector: [-0.006954097, -0.009932499, -0.001311474] # skip other numbers, not relevant to the test + exact: true + limit: 10 + - + $project: + _id: 0 + plot: 1 + title: 1 + score: + $meta: 'vectorSearchScore' diff --git a/generator/js2yaml.html b/generator/js2yaml.html index a0f8654af..31241adb1 100644 --- a/generator/js2yaml.html +++ b/generator/js2yaml.html @@ -28,6 +28,9 @@

Convert JS examples into Yaml

binary: BinData(0, "IA=="), empty_object: {}, empty_array: [], + objectId: ObjectId("5f0f1d9b1c9d440000f3f3f3"), + uuid: UUID("fac32260-b511-4c69-8485-a2be5b7dda9e"), + list: [1, 2, 3], } }, // First Stage @@ -90,6 +93,14 @@

Convert JS examples into Yaml

return new TaggedValue('bson_int64', value) } + function ObjectId(value) { + return new TaggedValue('bson_objectId', value) + } + + function UUID(value) { + return new TaggedValue('bson_uuid', value) + } + function convert(jsString) { try { return toYaml(eval(jsString), 1); @@ -109,6 +120,11 @@

Convert JS examples into Yaml

return ' []'; } + // Inline list of numbers + if (object.every(item => typeof item === 'number')) { + return ' [' + object.join(', ') + ']'; + } + return newline + '-' + object.map((item) => toYaml(item, indent + 1)).join(newline + '-'); } diff --git a/generator/src/OperatorTestGenerator.php b/generator/src/OperatorTestGenerator.php index a8e6e91cc..f665b9210 100644 --- a/generator/src/OperatorTestGenerator.php +++ b/generator/src/OperatorTestGenerator.php @@ -10,6 +10,7 @@ use MongoDB\BSON\Decimal128; use MongoDB\BSON\Document; use MongoDB\BSON\Int64; +use MongoDB\BSON\ObjectId; use MongoDB\BSON\Regex; use MongoDB\BSON\UTCDateTime; use MongoDB\Builder\Pipeline; @@ -27,6 +28,7 @@ use function base64_decode; use function basename; use function get_object_vars; +use function hex2bin; use function is_array; use function is_numeric; use function is_object; @@ -145,6 +147,8 @@ private function convertYamlTaggedValues(mixed $object): mixed 'bson_decimal128' => new Decimal128($value), 'bson_utcdatetime' => new UTCDateTime(is_numeric($value) ? $value : new DateTimeImmutable($value)), 'bson_binary' => new Binary(base64_decode($value)), + 'bson_objectId' => new ObjectId($value), + 'bson_uuid' => new Binary(hex2bin(str_replace('-', '', $value)), Binary::TYPE_UUID), default => throw new InvalidArgumentException(sprintf('Yaml tag "%s" is not supported.', $object->getTag())), }; } @@ -158,6 +162,7 @@ private function convertYamlTaggedValues(mixed $object): mixed } if (is_object($object)) { + $object = clone $object; foreach (get_object_vars($object) as $key => $value) { $object->{$key} = $this->convertYamlTaggedValues($value); } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 0d349c0d9..7b0912775 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -19,7 +19,7 @@ rector.php - src/Builder/(Accumulator|Expression|Query|Projection|Stage)/*\.php + src/Builder/(Accumulator|Expression|Query|Projection|Search|Stage)/*\.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 301c049ac..321bbc05a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -172,6 +172,11 @@
+ + + + + diff --git a/src/Builder/Search.php b/src/Builder/Search.php new file mode 100644 index 000000000..7cab84641 --- /dev/null +++ b/src/Builder/Search.php @@ -0,0 +1,10 @@ + 'path', + 'query' => 'query', + 'tokenOrder' => 'tokenOrder', + 'fuzzy' => 'fuzzy', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var string $query */ + public readonly string $query; + + /** @var Optional|string $tokenOrder */ + public readonly Optional|string $tokenOrder; + + /** @var Optional|Document|Serializable|array|stdClass $fuzzy */ + public readonly Optional|Document|Serializable|stdClass|array $fuzzy; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param string $query + * @param Optional|string $tokenOrder + * @param Optional|Document|Serializable|array|stdClass $fuzzy + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + string $query, + Optional|string $tokenOrder = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $fuzzy = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->query = $query; + $this->tokenOrder = $tokenOrder; + $this->fuzzy = $fuzzy; + $this->score = $score; + } +} diff --git a/src/Builder/Search/CompoundOperator.php b/src/Builder/Search/CompoundOperator.php new file mode 100644 index 000000000..27b8c2aeb --- /dev/null +++ b/src/Builder/Search/CompoundOperator.php @@ -0,0 +1,84 @@ + 'must', + 'mustNot' => 'mustNot', + 'should' => 'should', + 'filter' => 'filter', + 'minimumShouldMatch' => 'minimumShouldMatch', + 'score' => 'score', + ]; + + /** @var Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $must */ + public readonly Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $must; + + /** @var Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $mustNot */ + public readonly Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $mustNot; + + /** @var Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $should */ + public readonly Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $should; + + /** @var Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $filter */ + public readonly Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $filter; + + /** @var Optional|int $minimumShouldMatch */ + public readonly Optional|int $minimumShouldMatch; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $must + * @param Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $mustNot + * @param Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $should + * @param Optional|BSONArray|Document|PackedArray|SearchOperatorInterface|Serializable|array|stdClass $filter + * @param Optional|int $minimumShouldMatch + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $must = Optional::Undefined, + Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $mustNot = Optional::Undefined, + Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $should = Optional::Undefined, + Optional|Document|PackedArray|Serializable|SearchOperatorInterface|BSONArray|stdClass|array $filter = Optional::Undefined, + Optional|int $minimumShouldMatch = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->must = $must; + $this->mustNot = $mustNot; + $this->should = $should; + $this->filter = $filter; + $this->minimumShouldMatch = $minimumShouldMatch; + $this->score = $score; + } +} diff --git a/src/Builder/Search/EmbeddedDocumentOperator.php b/src/Builder/Search/EmbeddedDocumentOperator.php new file mode 100644 index 000000000..91f6c1f96 --- /dev/null +++ b/src/Builder/Search/EmbeddedDocumentOperator.php @@ -0,0 +1,57 @@ + 'path', 'operator' => 'operator', 'score' => 'score']; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var Document|SearchOperatorInterface|Serializable|array|stdClass $operator */ + public readonly Document|Serializable|SearchOperatorInterface|stdClass|array $operator; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->operator = $operator; + $this->score = $score; + } +} diff --git a/src/Builder/Search/EqualsOperator.php b/src/Builder/Search/EqualsOperator.php new file mode 100644 index 000000000..bbfe75b8e --- /dev/null +++ b/src/Builder/Search/EqualsOperator.php @@ -0,0 +1,59 @@ + 'path', 'value' => 'value', 'score' => 'score']; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var Binary|Decimal128|Int64|ObjectId|UTCDateTime|bool|float|int|null|string $value */ + public readonly Binary|Decimal128|Int64|ObjectId|UTCDateTime|bool|float|int|null|string $value; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param Binary|Decimal128|Int64|ObjectId|UTCDateTime|bool|float|int|null|string $value + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + Binary|Decimal128|Int64|ObjectId|UTCDateTime|bool|float|int|null|string $value, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->value = $value; + $this->score = $score; + } +} diff --git a/src/Builder/Search/ExistsOperator.php b/src/Builder/Search/ExistsOperator.php new file mode 100644 index 000000000..4330f130f --- /dev/null +++ b/src/Builder/Search/ExistsOperator.php @@ -0,0 +1,48 @@ + 'path', 'score' => 'score']; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->score = $score; + } +} diff --git a/src/Builder/Search/FacetOperator.php b/src/Builder/Search/FacetOperator.php new file mode 100644 index 000000000..15fc10830 --- /dev/null +++ b/src/Builder/Search/FacetOperator.php @@ -0,0 +1,49 @@ + 'facets', 'operator' => 'operator']; + + /** @var Document|Serializable|array|stdClass $facets */ + public readonly Document|Serializable|stdClass|array $facets; + + /** @var Optional|Document|SearchOperatorInterface|Serializable|array|stdClass $operator */ + public readonly Optional|Document|Serializable|SearchOperatorInterface|stdClass|array $operator; + + /** + * @param Document|Serializable|array|stdClass $facets + * @param Optional|Document|SearchOperatorInterface|Serializable|array|stdClass $operator + */ + public function __construct( + Document|Serializable|stdClass|array $facets, + Optional|Document|Serializable|SearchOperatorInterface|stdClass|array $operator = Optional::Undefined, + ) { + $this->facets = $facets; + $this->operator = $operator; + } +} diff --git a/src/Builder/Search/FactoryTrait.php b/src/Builder/Search/FactoryTrait.php new file mode 100644 index 000000000..3a7762521 --- /dev/null +++ b/src/Builder/Search/FactoryTrait.php @@ -0,0 +1,345 @@ + 'path', 'relation' => 'relation', 'geometry' => 'geometry', 'score' => 'score']; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var string $relation */ + public readonly string $relation; + + /** @var Document|GeometryInterface|Serializable|array|stdClass $geometry */ + public readonly Document|Serializable|GeometryInterface|stdClass|array $geometry; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param string $relation + * @param Document|GeometryInterface|Serializable|array|stdClass $geometry + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + string $relation, + Document|Serializable|GeometryInterface|stdClass|array $geometry, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->relation = $relation; + $this->geometry = $geometry; + $this->score = $score; + } +} diff --git a/src/Builder/Search/GeoWithinOperator.php b/src/Builder/Search/GeoWithinOperator.php new file mode 100644 index 000000000..dcf605697 --- /dev/null +++ b/src/Builder/Search/GeoWithinOperator.php @@ -0,0 +1,76 @@ + 'path', + 'box' => 'box', + 'circle' => 'circle', + 'geometry' => 'geometry', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var Optional|Document|Serializable|array|stdClass $box */ + public readonly Optional|Document|Serializable|stdClass|array $box; + + /** @var Optional|Document|Serializable|array|stdClass $circle */ + public readonly Optional|Document|Serializable|stdClass|array $circle; + + /** @var Optional|Document|GeometryInterface|Serializable|array|stdClass $geometry */ + public readonly Optional|Document|Serializable|GeometryInterface|stdClass|array $geometry; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param Optional|Document|Serializable|array|stdClass $box + * @param Optional|Document|Serializable|array|stdClass $circle + * @param Optional|Document|GeometryInterface|Serializable|array|stdClass $geometry + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + Optional|Document|Serializable|stdClass|array $box = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $circle = Optional::Undefined, + Optional|Document|Serializable|GeometryInterface|stdClass|array $geometry = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->box = $box; + $this->circle = $circle; + $this->geometry = $geometry; + $this->score = $score; + } +} diff --git a/src/Builder/Search/InOperator.php b/src/Builder/Search/InOperator.php new file mode 100644 index 000000000..f050a1679 --- /dev/null +++ b/src/Builder/Search/InOperator.php @@ -0,0 +1,65 @@ + 'path', 'value' => 'value', 'score' => 'score']; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var BSONArray|PackedArray|Type|array|bool|float|int|null|stdClass|string $value */ + public readonly PackedArray|Type|BSONArray|stdClass|array|bool|float|int|null|string $value; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param BSONArray|PackedArray|Type|array|bool|float|int|null|stdClass|string $value + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + PackedArray|Type|BSONArray|stdClass|array|bool|float|int|null|string $value, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + if (is_array($value) && ! array_is_list($value)) { + throw new InvalidArgumentException('Expected $value argument to be a list, got an associative array.'); + } + + $this->value = $value; + $this->score = $score; + } +} diff --git a/src/Builder/Search/MoreLikeThisOperator.php b/src/Builder/Search/MoreLikeThisOperator.php new file mode 100644 index 000000000..689508d53 --- /dev/null +++ b/src/Builder/Search/MoreLikeThisOperator.php @@ -0,0 +1,52 @@ + 'like', 'score' => 'score']; + + /** @var BSONArray|Document|PackedArray|Serializable|array|stdClass $like */ + public readonly Document|PackedArray|Serializable|BSONArray|stdClass|array $like; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param BSONArray|Document|PackedArray|Serializable|array|stdClass $like + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + Document|PackedArray|Serializable|BSONArray|stdClass|array $like, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->like = $like; + $this->score = $score; + } +} diff --git a/src/Builder/Search/NearOperator.php b/src/Builder/Search/NearOperator.php new file mode 100644 index 000000000..ab1b9b0c1 --- /dev/null +++ b/src/Builder/Search/NearOperator.php @@ -0,0 +1,64 @@ + 'path', 'origin' => 'origin', 'pivot' => 'pivot', 'score' => 'score']; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var Decimal128|Document|GeometryInterface|Int64|Serializable|UTCDateTime|array|float|int|stdClass $origin */ + public readonly Decimal128|Document|Int64|Serializable|UTCDateTime|GeometryInterface|stdClass|array|float|int $origin; + + /** @var Decimal128|Int64|float|int $pivot */ + public readonly Decimal128|Int64|float|int $pivot; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param Decimal128|Document|GeometryInterface|Int64|Serializable|UTCDateTime|array|float|int|stdClass $origin + * @param Decimal128|Int64|float|int $pivot + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + Decimal128|Document|Int64|Serializable|UTCDateTime|GeometryInterface|stdClass|array|float|int $origin, + Decimal128|Int64|float|int $pivot, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->origin = $origin; + $this->pivot = $pivot; + $this->score = $score; + } +} diff --git a/src/Builder/Search/PhraseOperator.php b/src/Builder/Search/PhraseOperator.php new file mode 100644 index 000000000..2bbb707a9 --- /dev/null +++ b/src/Builder/Search/PhraseOperator.php @@ -0,0 +1,83 @@ + 'path', + 'query' => 'query', + 'slop' => 'slop', + 'synonyms' => 'synonyms', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var BSONArray|PackedArray|array|string $query */ + public readonly PackedArray|BSONArray|array|string $query; + + /** @var Optional|int $slop */ + public readonly Optional|int $slop; + + /** @var Optional|string $synonyms */ + public readonly Optional|string $synonyms; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param BSONArray|PackedArray|array|string $query + * @param Optional|int $slop + * @param Optional|string $synonyms + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + PackedArray|BSONArray|array|string $query, + Optional|int $slop = Optional::Undefined, + Optional|string $synonyms = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + if (is_array($query) && ! array_is_list($query)) { + throw new InvalidArgumentException('Expected $query argument to be a list, got an associative array.'); + } + + $this->query = $query; + $this->slop = $slop; + $this->synonyms = $synonyms; + $this->score = $score; + } +} diff --git a/src/Builder/Search/QueryStringOperator.php b/src/Builder/Search/QueryStringOperator.php new file mode 100644 index 000000000..edc4d3471 --- /dev/null +++ b/src/Builder/Search/QueryStringOperator.php @@ -0,0 +1,40 @@ + 'defaultPath', 'query' => 'query']; + + /** @var array|string $defaultPath */ + public readonly array|string $defaultPath; + + /** @var string $query */ + public readonly string $query; + + /** + * @param array|string $defaultPath + * @param string $query + */ + public function __construct(array|string $defaultPath, string $query) + { + $this->defaultPath = $defaultPath; + $this->query = $query; + } +} diff --git a/src/Builder/Search/RangeOperator.php b/src/Builder/Search/RangeOperator.php new file mode 100644 index 000000000..a728d7477 --- /dev/null +++ b/src/Builder/Search/RangeOperator.php @@ -0,0 +1,85 @@ + 'path', + 'gt' => 'gt', + 'gte' => 'gte', + 'lt' => 'lt', + 'lte' => 'lte', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gt */ + public readonly Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gt; + + /** @var Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gte */ + public readonly Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gte; + + /** @var Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lt */ + public readonly Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lt; + + /** @var Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lte */ + public readonly Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lte; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gt + * @param Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gte + * @param Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lt + * @param Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lte + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gt = Optional::Undefined, + Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $gte = Optional::Undefined, + Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lt = Optional::Undefined, + Optional|Decimal128|Int64|ObjectId|UTCDateTime|float|int|string $lte = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->gt = $gt; + $this->gte = $gte; + $this->lt = $lt; + $this->lte = $lte; + $this->score = $score; + } +} diff --git a/src/Builder/Search/RegexOperator.php b/src/Builder/Search/RegexOperator.php new file mode 100644 index 000000000..6b2c2d63a --- /dev/null +++ b/src/Builder/Search/RegexOperator.php @@ -0,0 +1,67 @@ + 'path', + 'query' => 'query', + 'allowAnalyzedField' => 'allowAnalyzedField', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var string $query */ + public readonly string $query; + + /** @var Optional|bool $allowAnalyzedField */ + public readonly Optional|bool $allowAnalyzedField; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param string $query + * @param Optional|bool $allowAnalyzedField + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + string $query, + Optional|bool $allowAnalyzedField = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->query = $query; + $this->allowAnalyzedField = $allowAnalyzedField; + $this->score = $score; + } +} diff --git a/src/Builder/Search/TextOperator.php b/src/Builder/Search/TextOperator.php new file mode 100644 index 000000000..4ade6b434 --- /dev/null +++ b/src/Builder/Search/TextOperator.php @@ -0,0 +1,81 @@ + 'path', + 'query' => 'query', + 'fuzzy' => 'fuzzy', + 'matchCriteria' => 'matchCriteria', + 'synonyms' => 'synonyms', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var string $query */ + public readonly string $query; + + /** @var Optional|Document|Serializable|array|stdClass $fuzzy */ + public readonly Optional|Document|Serializable|stdClass|array $fuzzy; + + /** @var Optional|string $matchCriteria */ + public readonly Optional|string $matchCriteria; + + /** @var Optional|string $synonyms */ + public readonly Optional|string $synonyms; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param string $query + * @param Optional|Document|Serializable|array|stdClass $fuzzy + * @param Optional|string $matchCriteria + * @param Optional|string $synonyms + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + string $query, + Optional|Document|Serializable|stdClass|array $fuzzy = Optional::Undefined, + Optional|string $matchCriteria = Optional::Undefined, + Optional|string $synonyms = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->query = $query; + $this->fuzzy = $fuzzy; + $this->matchCriteria = $matchCriteria; + $this->synonyms = $synonyms; + $this->score = $score; + } +} diff --git a/src/Builder/Search/WildcardOperator.php b/src/Builder/Search/WildcardOperator.php new file mode 100644 index 000000000..ee481910e --- /dev/null +++ b/src/Builder/Search/WildcardOperator.php @@ -0,0 +1,66 @@ + 'path', + 'query' => 'query', + 'allowAnalyzedField' => 'allowAnalyzedField', + 'score' => 'score', + ]; + + /** @var array|string $path */ + public readonly array|string $path; + + /** @var string $query */ + public readonly string $query; + + /** @var Optional|bool $allowAnalyzedField */ + public readonly Optional|bool $allowAnalyzedField; + + /** @var Optional|Document|Serializable|array|stdClass $score */ + public readonly Optional|Document|Serializable|stdClass|array $score; + + /** + * @param array|string $path + * @param string $query + * @param Optional|bool $allowAnalyzedField + * @param Optional|Document|Serializable|array|stdClass $score + */ + public function __construct( + array|string $path, + string $query, + Optional|bool $allowAnalyzedField = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $score = Optional::Undefined, + ) { + $this->path = $path; + $this->query = $query; + $this->allowAnalyzedField = $allowAnalyzedField; + $this->score = $score; + } +} diff --git a/src/Builder/Stage/FactoryTrait.php b/src/Builder/Stage/FactoryTrait.php index 199cf64ef..95b0e6e37 100644 --- a/src/Builder/Stage/FactoryTrait.php +++ b/src/Builder/Stage/FactoryTrait.php @@ -24,6 +24,7 @@ use MongoDB\Builder\Type\ExpressionInterface; use MongoDB\Builder\Type\Optional; use MongoDB\Builder\Type\QueryInterface; +use MongoDB\Builder\Type\SearchOperatorInterface; use MongoDB\Builder\Type\Sort; use MongoDB\Model\BSONArray; use stdClass; @@ -537,11 +538,35 @@ public static function sample(int $size): SampleStage * NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/ - * @param Document|Serializable|array|stdClass $search - */ - public static function search(Document|Serializable|stdClass|array $search): SearchStage - { - return new SearchStage($search); + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + * @param Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to "default". + * @param Optional|Document|Serializable|array|stdClass $highlight Specifies the highlighting options for displaying search terms in their original context. + * @param Optional|bool $concurrent Parallelize search across segments on dedicated search nodes. + * If you don't have separate search nodes on your cluster, + * Atlas Search ignores this flag. If omitted, defaults to false. + * @param Optional|string $count Document that specifies the count options for retrieving a count of the results. + * @param Optional|string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. + * @param Optional|string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. + * @param Optional|bool $scoreDetails Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. + * @param Optional|Document|Serializable|array|stdClass $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. + * @param Optional|bool $returnStoredSource Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. + * @param Optional|Document|Serializable|array|stdClass $tracking Document that specifies the tracking option to retrieve analytics information on the search terms. + */ + public static function search( + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|string $index = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $highlight = Optional::Undefined, + Optional|bool $concurrent = Optional::Undefined, + Optional|string $count = Optional::Undefined, + Optional|string $searchAfter = Optional::Undefined, + Optional|string $searchBefore = Optional::Undefined, + Optional|bool $scoreDetails = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $sort = Optional::Undefined, + Optional|bool $returnStoredSource = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $tracking = Optional::Undefined, + ): SearchStage { + return new SearchStage($operator, $index, $highlight, $concurrent, $count, $searchAfter, $searchBefore, $scoreDetails, $sort, $returnStoredSource, $tracking); } /** @@ -549,11 +574,17 @@ public static function search(Document|Serializable|stdClass|array $search): Sea * NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/ - * @param Document|Serializable|array|stdClass $meta - */ - public static function searchMeta(Document|Serializable|stdClass|array $meta): SearchMetaStage - { - return new SearchMetaStage($meta); + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + * @param Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to default. + * @param Optional|Document|Serializable|array|stdClass $count Document that specifies the count options for retrieving a count of the results. + */ + public static function searchMeta( + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|string $index = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $count = Optional::Undefined, + ): SearchMetaStage { + return new SearchMetaStage($operator, $index, $count); } /** @@ -678,4 +709,29 @@ public static function unwind( ): UnwindStage { return new UnwindStage($path, $includeArrayIndex, $preserveNullAndEmptyArrays); } + + /** + * The $vectorSearch stage performs an ANN or ENN search on a vector in the specified field. + * + * @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/ + * @param string $index Name of the Atlas Vector Search index to use. + * @param int $limit Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. + * @param array|string $path Indexed vector type field to search. + * @param BSONArray|PackedArray|array $queryVector Array of numbers that represent the query vector. The number type must match the indexed field value type. + * @param Optional|bool $exact This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. + * @param Optional|QueryInterface|array $filter Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. + * @param Optional|int $numCandidates This field is required if exact is false or omitted. + * Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). + */ + public static function vectorSearch( + string $index, + int $limit, + array|string $path, + PackedArray|BSONArray|array $queryVector, + Optional|bool $exact = Optional::Undefined, + Optional|QueryInterface|array $filter = Optional::Undefined, + Optional|int $numCandidates = Optional::Undefined, + ): VectorSearchStage { + return new VectorSearchStage($index, $limit, $path, $queryVector, $exact, $filter, $numCandidates); + } } diff --git a/src/Builder/Stage/FluentFactoryTrait.php b/src/Builder/Stage/FluentFactoryTrait.php index 6f468322d..757a09a0b 100644 --- a/src/Builder/Stage/FluentFactoryTrait.php +++ b/src/Builder/Stage/FluentFactoryTrait.php @@ -26,6 +26,7 @@ use MongoDB\Builder\Type\FieldQueryInterface; use MongoDB\Builder\Type\Optional; use MongoDB\Builder\Type\QueryInterface; +use MongoDB\Builder\Type\SearchOperatorInterface; use MongoDB\Builder\Type\Sort; use MongoDB\Builder\Type\StageInterface; use MongoDB\Model\BSONArray; @@ -605,11 +606,35 @@ public function sample(int $size): static * NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/ - * @param Document|Serializable|array|stdClass $search - */ - public function search(Document|Serializable|stdClass|array $search): static - { - $this->pipeline[] = Stage::search($search); + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + * @param Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to "default". + * @param Optional|Document|Serializable|array|stdClass $highlight Specifies the highlighting options for displaying search terms in their original context. + * @param Optional|bool $concurrent Parallelize search across segments on dedicated search nodes. + * If you don't have separate search nodes on your cluster, + * Atlas Search ignores this flag. If omitted, defaults to false. + * @param Optional|string $count Document that specifies the count options for retrieving a count of the results. + * @param Optional|string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. + * @param Optional|string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. + * @param Optional|bool $scoreDetails Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. + * @param Optional|Document|Serializable|array|stdClass $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. + * @param Optional|bool $returnStoredSource Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. + * @param Optional|Document|Serializable|array|stdClass $tracking Document that specifies the tracking option to retrieve analytics information on the search terms. + */ + public function search( + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|string $index = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $highlight = Optional::Undefined, + Optional|bool $concurrent = Optional::Undefined, + Optional|string $count = Optional::Undefined, + Optional|string $searchAfter = Optional::Undefined, + Optional|string $searchBefore = Optional::Undefined, + Optional|bool $scoreDetails = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $sort = Optional::Undefined, + Optional|bool $returnStoredSource = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $tracking = Optional::Undefined, + ): static { + $this->pipeline[] = Stage::search($operator, $index, $highlight, $concurrent, $count, $searchAfter, $searchBefore, $scoreDetails, $sort, $returnStoredSource, $tracking); return $this; } @@ -619,11 +644,17 @@ public function search(Document|Serializable|stdClass|array $search): static * NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/ - * @param Document|Serializable|array|stdClass $meta - */ - public function searchMeta(Document|Serializable|stdClass|array $meta): static - { - $this->pipeline[] = Stage::searchMeta($meta); + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + * @param Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to default. + * @param Optional|Document|Serializable|array|stdClass $count Document that specifies the count options for retrieving a count of the results. + */ + public function searchMeta( + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|string $index = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $count = Optional::Undefined, + ): static { + $this->pipeline[] = Stage::searchMeta($operator, $index, $count); return $this; } @@ -767,4 +798,31 @@ public function unwind( return $this; } + + /** + * The $vectorSearch stage performs an ANN or ENN search on a vector in the specified field. + * + * @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/ + * @param string $index Name of the Atlas Vector Search index to use. + * @param int $limit Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. + * @param array|string $path Indexed vector type field to search. + * @param BSONArray|PackedArray|array $queryVector Array of numbers that represent the query vector. The number type must match the indexed field value type. + * @param Optional|bool $exact This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. + * @param Optional|QueryInterface|array $filter Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. + * @param Optional|int $numCandidates This field is required if exact is false or omitted. + * Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). + */ + public function vectorSearch( + string $index, + int $limit, + array|string $path, + PackedArray|BSONArray|array $queryVector, + Optional|bool $exact = Optional::Undefined, + Optional|QueryInterface|array $filter = Optional::Undefined, + Optional|int $numCandidates = Optional::Undefined, + ): static { + $this->pipeline[] = Stage::vectorSearch($index, $limit, $path, $queryVector, $exact, $filter, $numCandidates); + + return $this; + } } diff --git a/src/Builder/Stage/SearchMetaStage.php b/src/Builder/Stage/SearchMetaStage.php index 88f05bec1..14687161b 100644 --- a/src/Builder/Stage/SearchMetaStage.php +++ b/src/Builder/Stage/SearchMetaStage.php @@ -12,6 +12,8 @@ use MongoDB\BSON\Serializable; use MongoDB\Builder\Type\Encode; use MongoDB\Builder\Type\OperatorInterface; +use MongoDB\Builder\Type\Optional; +use MongoDB\Builder\Type\SearchOperatorInterface; use MongoDB\Builder\Type\StageInterface; use stdClass; @@ -24,18 +26,35 @@ */ final class SearchMetaStage implements StageInterface, OperatorInterface { - public const ENCODE = Encode::Single; + public const ENCODE = Encode::Object; public const NAME = '$searchMeta'; - public const PROPERTIES = ['meta' => 'meta']; + public const PROPERTIES = ['operator' => null, 'index' => 'index', 'count' => 'count']; - /** @var Document|Serializable|array|stdClass $meta */ - public readonly Document|Serializable|stdClass|array $meta; + /** + * @var Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + */ + public readonly Document|Serializable|SearchOperatorInterface|stdClass|array $operator; + + /** @var Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to default. */ + public readonly Optional|string $index; + + /** @var Optional|Document|Serializable|array|stdClass $count Document that specifies the count options for retrieving a count of the results. */ + public readonly Optional|Document|Serializable|stdClass|array $count; /** - * @param Document|Serializable|array|stdClass $meta + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + * @param Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to default. + * @param Optional|Document|Serializable|array|stdClass $count Document that specifies the count options for retrieving a count of the results. */ - public function __construct(Document|Serializable|stdClass|array $meta) - { - $this->meta = $meta; + public function __construct( + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|string $index = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $count = Optional::Undefined, + ) { + $this->operator = $operator; + $this->index = $index; + $this->count = $count; } } diff --git a/src/Builder/Stage/SearchStage.php b/src/Builder/Stage/SearchStage.php index 188a2ece4..bd224dba9 100644 --- a/src/Builder/Stage/SearchStage.php +++ b/src/Builder/Stage/SearchStage.php @@ -12,6 +12,8 @@ use MongoDB\BSON\Serializable; use MongoDB\Builder\Type\Encode; use MongoDB\Builder\Type\OperatorInterface; +use MongoDB\Builder\Type\Optional; +use MongoDB\Builder\Type\SearchOperatorInterface; use MongoDB\Builder\Type\StageInterface; use stdClass; @@ -24,18 +26,102 @@ */ final class SearchStage implements StageInterface, OperatorInterface { - public const ENCODE = Encode::Single; + public const ENCODE = Encode::Object; public const NAME = '$search'; - public const PROPERTIES = ['search' => 'search']; - /** @var Document|Serializable|array|stdClass $search */ - public readonly Document|Serializable|stdClass|array $search; + public const PROPERTIES = [ + 'operator' => null, + 'index' => 'index', + 'highlight' => 'highlight', + 'concurrent' => 'concurrent', + 'count' => 'count', + 'searchAfter' => 'searchAfter', + 'searchBefore' => 'searchBefore', + 'scoreDetails' => 'scoreDetails', + 'sort' => 'sort', + 'returnStoredSource' => 'returnStoredSource', + 'tracking' => 'tracking', + ]; /** - * @param Document|Serializable|array|stdClass $search + * @var Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. */ - public function __construct(Document|Serializable|stdClass|array $search) - { - $this->search = $search; + public readonly Document|Serializable|SearchOperatorInterface|stdClass|array $operator; + + /** @var Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to "default". */ + public readonly Optional|string $index; + + /** @var Optional|Document|Serializable|array|stdClass $highlight Specifies the highlighting options for displaying search terms in their original context. */ + public readonly Optional|Document|Serializable|stdClass|array $highlight; + + /** + * @var Optional|bool $concurrent Parallelize search across segments on dedicated search nodes. + * If you don't have separate search nodes on your cluster, + * Atlas Search ignores this flag. If omitted, defaults to false. + */ + public readonly Optional|bool $concurrent; + + /** @var Optional|string $count Document that specifies the count options for retrieving a count of the results. */ + public readonly Optional|string $count; + + /** @var Optional|string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. */ + public readonly Optional|string $searchAfter; + + /** @var Optional|string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. */ + public readonly Optional|string $searchBefore; + + /** @var Optional|bool $scoreDetails Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. */ + public readonly Optional|bool $scoreDetails; + + /** @var Optional|Document|Serializable|array|stdClass $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. */ + public readonly Optional|Document|Serializable|stdClass|array $sort; + + /** @var Optional|bool $returnStoredSource Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. */ + public readonly Optional|bool $returnStoredSource; + + /** @var Optional|Document|Serializable|array|stdClass $tracking Document that specifies the tracking option to retrieve analytics information on the search terms. */ + public readonly Optional|Document|Serializable|stdClass|array $tracking; + + /** + * @param Document|SearchOperatorInterface|Serializable|array|stdClass $operator Operator to search with. You can provide a specific operator or use + * the compound operator to run a compound query with multiple operators. + * @param Optional|string $index Name of the Atlas Search index to use. If omitted, defaults to "default". + * @param Optional|Document|Serializable|array|stdClass $highlight Specifies the highlighting options for displaying search terms in their original context. + * @param Optional|bool $concurrent Parallelize search across segments on dedicated search nodes. + * If you don't have separate search nodes on your cluster, + * Atlas Search ignores this flag. If omitted, defaults to false. + * @param Optional|string $count Document that specifies the count options for retrieving a count of the results. + * @param Optional|string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. + * @param Optional|string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. + * @param Optional|bool $scoreDetails Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. + * @param Optional|Document|Serializable|array|stdClass $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. + * @param Optional|bool $returnStoredSource Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. + * @param Optional|Document|Serializable|array|stdClass $tracking Document that specifies the tracking option to retrieve analytics information on the search terms. + */ + public function __construct( + Document|Serializable|SearchOperatorInterface|stdClass|array $operator, + Optional|string $index = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $highlight = Optional::Undefined, + Optional|bool $concurrent = Optional::Undefined, + Optional|string $count = Optional::Undefined, + Optional|string $searchAfter = Optional::Undefined, + Optional|string $searchBefore = Optional::Undefined, + Optional|bool $scoreDetails = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $sort = Optional::Undefined, + Optional|bool $returnStoredSource = Optional::Undefined, + Optional|Document|Serializable|stdClass|array $tracking = Optional::Undefined, + ) { + $this->operator = $operator; + $this->index = $index; + $this->highlight = $highlight; + $this->concurrent = $concurrent; + $this->count = $count; + $this->searchAfter = $searchAfter; + $this->searchBefore = $searchBefore; + $this->scoreDetails = $scoreDetails; + $this->sort = $sort; + $this->returnStoredSource = $returnStoredSource; + $this->tracking = $tracking; } } diff --git a/src/Builder/Stage/VectorSearchStage.php b/src/Builder/Stage/VectorSearchStage.php new file mode 100644 index 000000000..e8f7738cc --- /dev/null +++ b/src/Builder/Stage/VectorSearchStage.php @@ -0,0 +1,104 @@ + 'index', + 'limit' => 'limit', + 'path' => 'path', + 'queryVector' => 'queryVector', + 'exact' => 'exact', + 'filter' => 'filter', + 'numCandidates' => 'numCandidates', + ]; + + /** @var string $index Name of the Atlas Vector Search index to use. */ + public readonly string $index; + + /** @var int $limit Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. */ + public readonly int $limit; + + /** @var array|string $path Indexed vector type field to search. */ + public readonly array|string $path; + + /** @var BSONArray|PackedArray|array $queryVector Array of numbers that represent the query vector. The number type must match the indexed field value type. */ + public readonly PackedArray|BSONArray|array $queryVector; + + /** @var Optional|bool $exact This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. */ + public readonly Optional|bool $exact; + + /** @var Optional|QueryInterface|array $filter Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. */ + public readonly Optional|QueryInterface|array $filter; + + /** + * @var Optional|int $numCandidates This field is required if exact is false or omitted. + * Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). + */ + public readonly Optional|int $numCandidates; + + /** + * @param string $index Name of the Atlas Vector Search index to use. + * @param int $limit Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. + * @param array|string $path Indexed vector type field to search. + * @param BSONArray|PackedArray|array $queryVector Array of numbers that represent the query vector. The number type must match the indexed field value type. + * @param Optional|bool $exact This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. + * @param Optional|QueryInterface|array $filter Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. + * @param Optional|int $numCandidates This field is required if exact is false or omitted. + * Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). + */ + public function __construct( + string $index, + int $limit, + array|string $path, + PackedArray|BSONArray|array $queryVector, + Optional|bool $exact = Optional::Undefined, + Optional|QueryInterface|array $filter = Optional::Undefined, + Optional|int $numCandidates = Optional::Undefined, + ) { + $this->index = $index; + $this->limit = $limit; + $this->path = $path; + if (is_array($queryVector) && ! array_is_list($queryVector)) { + throw new InvalidArgumentException('Expected $queryVector argument to be a list, got an associative array.'); + } + + $this->queryVector = $queryVector; + $this->exact = $exact; + if (is_array($filter)) { + $filter = QueryObject::create($filter); + } + + $this->filter = $filter; + $this->numCandidates = $numCandidates; + } +} diff --git a/src/Builder/Type/Encode.php b/src/Builder/Type/Encode.php index d03491623..120c2ee46 100644 --- a/src/Builder/Type/Encode.php +++ b/src/Builder/Type/Encode.php @@ -29,6 +29,11 @@ enum Encode */ 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/SearchOperatorInterface.php b/src/Builder/Type/SearchOperatorInterface.php new file mode 100644 index 000000000..c144d4ebe --- /dev/null +++ b/src/Builder/Type/SearchOperatorInterface.php @@ -0,0 +1,7 @@ +assertSamePipeline(Pipelines::AutocompleteAcrossMultipleFields, $pipeline); + } + + public function testBasic(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::autocomplete( + query: 'off', + path: 'title', + ), + ), + Stage::limit(10), + Stage::project(_id: 0, title: 1), + ); + + $this->assertSamePipeline(Pipelines::AutocompleteBasic, $pipeline); + } + + public function testFuzzy(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::autocomplete( + query: 'pre', + path: 'title', + fuzzy: object( + maxEdits: 1, + prefixLength: 1, + maxExpansions: 256, + ), + ), + ), + Stage::limit(10), + Stage::project(_id: 0, title: 1), + ); + + $this->assertSamePipeline(Pipelines::AutocompleteFuzzy, $pipeline); + } + + public function testHighlighting(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::autocomplete( + query: 'ger', + path: 'title', + ), + highlight: object( + path: 'title', + ), + ), + Stage::limit(5), + Stage::project( + score: ['$meta' => 'searchScore'], + _id: 0, + title: 1, + highlights: ['$meta' => 'searchHighlights'], + ), + ); + + $this->assertSamePipeline(Pipelines::AutocompleteHighlighting, $pipeline); + } + + public function testTokenOrderAny(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::autocomplete( + query: 'men with', + path: 'title', + tokenOrder: 'any', + ), + ), + Stage::limit(4), + Stage::project(_id: 0, title: 1), + ); + + $this->assertSamePipeline(Pipelines::AutocompleteTokenOrderAny, $pipeline); + } + + public function testTokenOrderSequential(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::autocomplete( + query: 'men with', + path: 'title', + tokenOrder: 'sequential', + ), + ), + Stage::limit(4), + Stage::project(_id: 0, title: 1), + ); + + $this->assertSamePipeline(Pipelines::AutocompleteTokenOrderSequential, $pipeline); + } +} diff --git a/tests/Builder/Search/CompoundOperatorTest.php b/tests/Builder/Search/CompoundOperatorTest.php new file mode 100644 index 000000000..8d5d69aed --- /dev/null +++ b/tests/Builder/Search/CompoundOperatorTest.php @@ -0,0 +1,157 @@ +assertSamePipeline(Pipelines::CompoundFilter, $pipeline); + } + + public function testMinimumShouldMatch(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + must: [ + Search::text( + path: 'description', + query: 'varieties', + ), + ], + should: [ + Search::text( + path: 'description', + query: 'Fuji', + ), + Search::text( + path: 'description', + query: 'Golden Delicious', + ), + ], + minimumShouldMatch: 1, + ), + ), + ); + + $this->assertSamePipeline(Pipelines::CompoundMinimumShouldMatch, $pipeline); + } + + public function testMustAndMustNot(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + must: [ + Search::text( + path: 'description', + query: 'varieties', + ), + ], + mustNot: [ + Search::text( + path: 'description', + query: 'apples', + ), + ], + ), + ), + ); + + $this->assertSamePipeline(Pipelines::CompoundMustAndMustNot, $pipeline); + } + + public function testMustAndShould(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + must: [ + Search::text( + path: 'description', + query: 'varieties', + ), + ], + should: [ + Search::text( + path: 'description', + query: 'Fuji', + ), + ], + ), + ), + Stage::project( + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::CompoundMustAndShould, $pipeline); + } + + public function testNested(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + should: [ + Search::text( + path: 'type', + query: 'apple', + ), + Search::compound( + must: [ + Search::text( + path: 'category', + query: 'organic', + ), + Search::equals( + path: 'in_stock', + value: true, + ), + ], + ), + ], + minimumShouldMatch: 1, + ), + ), + ); + + $this->assertSamePipeline(Pipelines::CompoundNested, $pipeline); + } +} diff --git a/tests/Builder/Search/EmbeddedDocumentOperatorTest.php b/tests/Builder/Search/EmbeddedDocumentOperatorTest.php new file mode 100644 index 000000000..b83790c83 --- /dev/null +++ b/tests/Builder/Search/EmbeddedDocumentOperatorTest.php @@ -0,0 +1,167 @@ + 1, + 'items.tags' => 1, + ], + _id: 0, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::EmbeddedDocumentBasic, $pipeline); + } + + public function testFacet(): void + { + $pipeline = new Pipeline( + Stage::searchMeta( + Search::facet( + facets: object( + purchaseMethodFacet: object( + type: 'string', + path: 'purchaseMethod', + ), + ), + operator: Search::embeddedDocument( + path: 'items', + operator: Search::compound( + must: [ + Search::text( + path: 'items.tags', + query: 'school', + ), + ], + should: [ + Search::text( + path: 'items.name', + query: 'backpack', + ), + ], + ), + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EmbeddedDocumentFacet, $pipeline); + } + + public function testQueryAndSort(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::embeddedDocument( + path: 'items', + operator: + Search::text( + path: 'items.name', + query: 'laptop', + ), + ), + sort: ['items.tags' => Sort::Asc], + ), + Stage::limit(5), + Stage::project( + ...[ + 'items.name' => 1, + 'items.tags' => 1, + ], + _id: 0, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::EmbeddedDocumentQueryAndSort, $pipeline); + } + + public function testQueryForMatchingEmbeddedDocumentsOnly(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::embeddedDocument( + path: 'items', + operator: + Search::compound( + must: [ + Search::range( + path: 'items.quantity', + gt: 2, + ), + Search::exists( + path: 'items.price', + ), + Search::text( + path: 'items.tags', + query: 'school', + ), + ], + ), + ), + ), + Stage::limit(2), + Stage::project( + _id: 0, + storeLocation: 1, + items: Expression::filter( + input: Expression::arrayFieldPath('items'), + cond: Expression::and( + Expression::ifNull('$$this.price', 'false'), + Expression::gt(Expression::variable('this.quantity'), 2), + Expression::in('office', Expression::variable('this.tags')), + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EmbeddedDocumentQueryForMatchingEmbeddedDocumentsOnly, $pipeline); + } +} diff --git a/tests/Builder/Search/EqualsOperatorTest.php b/tests/Builder/Search/EqualsOperatorTest.php new file mode 100644 index 000000000..6cd8ae9e1 --- /dev/null +++ b/tests/Builder/Search/EqualsOperatorTest.php @@ -0,0 +1,125 @@ + 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsBoolean, $pipeline); + } + + public function testDate(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::equals( + path: 'account_created', + value: new UTCDateTime(new DateTimeImmutable('2022-05-04T05:01:08')), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsDate, $pipeline); + } + + public function testNull(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::equals( + path: 'job_title', + value: null, + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsNull, $pipeline); + } + + public function testNumber(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::equals( + path: 'employee_number', + value: 259, + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsNumber, $pipeline); + } + + public function testObjectId(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::equals( + path: 'teammates', + value: new ObjectId('5a9427648b0beebeb69589a1'), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsObjectId, $pipeline); + } + + public function testString(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::equals( + path: 'name', + value: 'jim hall', + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsString, $pipeline); + } + + public function testUUID(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::equals( + path: 'uuid', + value: new Binary(hex2bin('fac32260b5114c698485a2be5b7dda9e'), Binary::TYPE_UUID), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::EqualsUUID, $pipeline); + } +} diff --git a/tests/Builder/Search/ExistsOperatorTest.php b/tests/Builder/Search/ExistsOperatorTest.php new file mode 100644 index 000000000..5666a1099 --- /dev/null +++ b/tests/Builder/Search/ExistsOperatorTest.php @@ -0,0 +1,67 @@ +assertSamePipeline(Pipelines::ExistsBasic, $pipeline); + } + + public function testCompound(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + must: [ + Search::exists( + path: 'type', + ), + Search::text( + path: 'type', + query: 'apple', + ), + ], + should: Search::text( + path: 'description', + query: 'fuji', + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::ExistsCompound, $pipeline); + } + + public function testEmbedded(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::exists( + path: 'quantities.lemons', + ), + ), + ); + + $this->assertSamePipeline(Pipelines::ExistsEmbedded, $pipeline); + } +} diff --git a/tests/Builder/Search/FacetOperatorTest.php b/tests/Builder/Search/FacetOperatorTest.php new file mode 100644 index 000000000..3be124bec --- /dev/null +++ b/tests/Builder/Search/FacetOperatorTest.php @@ -0,0 +1,61 @@ +assertSamePipeline(Pipelines::FacetFacet, $pipeline); + } +} diff --git a/tests/Builder/Search/GeoShapeOperatorTest.php b/tests/Builder/Search/GeoShapeOperatorTest.php new file mode 100644 index 000000000..b5e748660 --- /dev/null +++ b/tests/Builder/Search/GeoShapeOperatorTest.php @@ -0,0 +1,204 @@ + 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::GeoShapeDisjoint, $pipeline); + } + + public function testIntersect(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::geoShape( + relation: 'intersects', + geometry: object( + type: 'MultiPolygon', + coordinates: [ + [ + [ + [ + 2.16942, + 41.40082, + ], + [ + 2.17963, + 41.40087, + ], + [ + 2.18146, + 41.39716, + ], + [ + 2.15533, + 41.40686, + ], + [ + 2.14596, + 41.38475, + ], + [ + 2.17519, + 41.41035, + ], + [ + 2.16942, + 41.40082, + ], + ], + ], + [ + [ + [ + 2.16365, + 41.39416, + ], + [ + 2.16963, + 41.39726, + ], + [ + 2.15395, + 41.38005, + ], + [ + 2.17935, + 41.43038, + ], + [ + 2.16365, + 41.39416, + ], + ], + ], + ], + ), + path: 'address.location', + ), + ), + Stage::limit(3), + Stage::project( + _id: 0, + name: 1, + address: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::GeoShapeIntersect, $pipeline); + } + + public function testWithin(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::geoShape( + relation: 'within', + geometry: object( + type: 'Polygon', + coordinates: [ + [ + [ + -74.3994140625, + 40.5305017757, + ], + [ + -74.7290039063, + 40.5805846641, + ], + [ + -74.7729492188, + 40.9467136651, + ], + [ + -74.0698242188, + 41.1290213475, + ], + [ + -73.65234375, + 40.9964840144, + ], + [ + -72.6416015625, + 40.9467136651, + ], + [ + -72.3559570313, + 40.7971774152, + ], + [ + -74.3994140625, + 40.5305017757, + ], + ], + ], + ), + path: 'address.location', + ), + ), + Stage::limit(3), + Stage::project( + _id: 0, + name: 1, + address: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::GeoShapeWithin, $pipeline); + } +} diff --git a/tests/Builder/Search/GeoWithinOperatorTest.php b/tests/Builder/Search/GeoWithinOperatorTest.php new file mode 100644 index 000000000..3a6a6b0af --- /dev/null +++ b/tests/Builder/Search/GeoWithinOperatorTest.php @@ -0,0 +1,124 @@ +assertSamePipeline(Pipelines::GeoWithinBox, $pipeline); + } + + public function testCircle(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::geoWithin( + path: 'address.location', + circle: object( + center: object( + type: 'Point', + coordinates: [ + -73.54, + 45.54, + ], + ), + radius: 1600, + ), + ), + ), + Stage::limit(3), + Stage::project( + _id: 0, + name: 1, + address: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::GeoWithinCircle, $pipeline); + } + + public function testGeometry(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::geoWithin( + path: 'address.location', + geometry: object( + type: 'Polygon', + coordinates: [ + [ + [ + -161.323242, + 22.512557, + ], + [ + -152.446289, + 22.065278, + ], + [ + -156.09375, + 17.811456, + ], + [ + -161.323242, + 22.512557, + ], + ], + ], + ), + ), + ), + Stage::limit(3), + Stage::project( + _id: 0, + name: 1, + address: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::GeoWithinGeometry, $pipeline); + } +} diff --git a/tests/Builder/Search/InOperatorTest.php b/tests/Builder/Search/InOperatorTest.php new file mode 100644 index 000000000..e6d1af57c --- /dev/null +++ b/tests/Builder/Search/InOperatorTest.php @@ -0,0 +1,101 @@ +assertSamePipeline(Pipelines::InArrayValueFieldMatch, $pipeline); + } + + public function testCompoundQueryMatch(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + must: [ + Search::in( + path: 'name', + value: [ + 'james sanchez', + 'jennifer lawrence', + ], + ), + ], + should: [ + Search::in( + path: '_id', + value: [ + new ObjectId('5ca4bbcea2dd94ee58162a72'), + new ObjectId('5ca4bbcea2dd94ee58162a91'), + ], + ), + ], + ), + ), + Stage::limit(5), + Stage::project( + _id: 1, + name: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::InCompoundQueryMatch, $pipeline); + } + + public function testSingleValueFieldMatch(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::in( + path: 'birthdate', + value: [ + new UTCDateTime(new DateTimeImmutable('1977-03-02T02:20:31')), + new UTCDateTime(new DateTimeImmutable('1977-03-01T00:00:00')), + new UTCDateTime(new DateTimeImmutable('1977-05-06T21:57:35')), + ], + ), + ), + Stage::project( + _id: 0, + name: 1, + birthdate: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::InSingleValueFieldMatch, $pipeline); + } +} diff --git a/tests/Builder/Search/MoreLikeThisOperatorTest.php b/tests/Builder/Search/MoreLikeThisOperatorTest.php new file mode 100644 index 000000000..a83c03559 --- /dev/null +++ b/tests/Builder/Search/MoreLikeThisOperatorTest.php @@ -0,0 +1,115 @@ +assertSamePipeline(Pipelines::MoreLikeThisInputDocumentExcludedInResults, $pipeline); + } + + public function testMultipleAnalyzers(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::compound( + mustNot: [ + Search::equals( + path: '_id', + value: new ObjectId('573a1394f29313caabcde9ef'), + ), + ], + should: [ + Search::moreLikeThis( + like: object( + _id: new ObjectId('573a1396f29313caabce4a9a'), + genres: [ + 'Crime', + 'Drama', + ], + title: 'The Godfather', + ), + ), + ], + ), + ), + Stage::limit(10), + Stage::project( + title: 1, + genres: 1, + _id: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::MoreLikeThisMultipleAnalyzers, $pipeline); + } + + public function testSingleDocumentWithMultipleFields(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::moreLikeThis( + like: object( + title: 'The Godfather', + genres: 'action', + ), + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + title: 1, + released: 1, + genres: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::MoreLikeThisSingleDocumentWithMultipleFields, $pipeline); + } +} diff --git a/tests/Builder/Search/NearOperatorTest.php b/tests/Builder/Search/NearOperatorTest.php new file mode 100644 index 000000000..45a48e0d5 --- /dev/null +++ b/tests/Builder/Search/NearOperatorTest.php @@ -0,0 +1,128 @@ + 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::NearCompound, $pipeline); + } + + public function testDate(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::near( + path: 'released', + origin: new UTCDateTime(new DateTimeImmutable('1915-09-13T00:00:00.000+00:00')), + pivot: 7776000000, + ), + index: 'releaseddate', + ), + Stage::limit(3), + Stage::project( + _id: 0, + title: 1, + released: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::NearDate, $pipeline); + } + + public function testGeoJSONPoint(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::near( + path: 'address.location', + origin: object( + type: 'Point', + coordinates: [ + -8.61308, + 41.1413, + ], + ), + pivot: 1000, + ), + ), + Stage::limit(3), + Stage::project( + _id: 0, + name: 1, + address: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::NearGeoJSONPoint, $pipeline); + } + + public function testNumber(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::near( + path: 'runtime', + origin: 279, + pivot: 2, + ), + index: 'runtimes', + ), + Stage::limit(7), + Stage::project( + _id: 0, + title: 1, + runtime: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::NearNumber, $pipeline); + } +} diff --git a/tests/Builder/Search/PhraseOperatorTest.php b/tests/Builder/Search/PhraseOperatorTest.php new file mode 100644 index 000000000..a045e9c12 --- /dev/null +++ b/tests/Builder/Search/PhraseOperatorTest.php @@ -0,0 +1,102 @@ + 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::PhraseMultiplePhrase, $pipeline); + } + + public function testPhraseSlop(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::phrase( + path: 'title', + query: 'men women', + slop: 5, + ), + ), + Stage::project( + _id: 0, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::PhrasePhraseSlop, $pipeline); + } + + public function testPhraseSynonyms(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::phrase( + path: 'plot', + query: 'automobile race', + slop: 5, + synonyms: 'my_synonyms', + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + plot: 1, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::PhrasePhraseSynonyms, $pipeline); + } + + public function testSinglePhrase(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::phrase( + path: 'title', + query: 'new york', + ), + ), + Stage::limit(10), + Stage::project( + _id: 0, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::PhraseSinglePhrase, $pipeline); + } +} diff --git a/tests/Builder/Search/Pipelines.php b/tests/Builder/Search/Pipelines.php new file mode 100644 index 000000000..fa94f8c9a --- /dev/null +++ b/tests/Builder/Search/Pipelines.php @@ -0,0 +1,2814 @@ +assertSamePipeline(Pipelines::QueryStringBooleanOperatorQueries, $pipeline); + } +} diff --git a/tests/Builder/Search/RangeOperatorTest.php b/tests/Builder/Search/RangeOperatorTest.php new file mode 100644 index 000000000..9606014ed --- /dev/null +++ b/tests/Builder/Search/RangeOperatorTest.php @@ -0,0 +1,122 @@ +assertSamePipeline(Pipelines::RangeDate, $pipeline); + } + + public function testNumberGteLte(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::range( + path: 'runtime', + gte: 2, + lte: 3, + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + title: 1, + runtime: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::RangeNumberGteLte, $pipeline); + } + + public function testNumberLte(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::range( + path: 'runtime', + lte: 2, + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + title: 1, + runtime: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::RangeNumberLte, $pipeline); + } + + public function testObjectId(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::range( + path: '_id', + gte: new ObjectId('573a1396f29313caabce4a9a'), + lte: new ObjectId('573a1396f29313caabce4ae7'), + ), + ), + Stage::project( + _id: 1, + title: 1, + released: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::RangeObjectId, $pipeline); + } + + public function testString(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::range( + path: 'title', + gt: 'city', + lt: 'country', + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + title: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::RangeString, $pipeline); + } +} diff --git a/tests/Builder/Search/RegexOperatorTest.php b/tests/Builder/Search/RegexOperatorTest.php new file mode 100644 index 000000000..b95f518a0 --- /dev/null +++ b/tests/Builder/Search/RegexOperatorTest.php @@ -0,0 +1,34 @@ +assertSamePipeline(Pipelines::RegexRegex, $pipeline); + } +} diff --git a/tests/Builder/Search/TextOperatorTest.php b/tests/Builder/Search/TextOperatorTest.php new file mode 100644 index 000000000..12709740e --- /dev/null +++ b/tests/Builder/Search/TextOperatorTest.php @@ -0,0 +1,194 @@ + 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextBasic, $pipeline); + } + + public function testFuzzyDefault(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: 'title', + query: 'naw yark', + fuzzy: object(), + ), + ), + Stage::limit(10), + Stage::project( + _id: 0, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextFuzzyDefault, $pipeline); + } + + public function testFuzzyMaxExpansions(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: 'title', + query: 'naw yark', + fuzzy: object( + maxEdits: 1, + maxExpansions: 100, + ), + ), + ), + Stage::limit(10), + Stage::project( + _id: 0, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextFuzzyMaxExpansions, $pipeline); + } + + public function testFuzzyPrefixLength(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: 'title', + query: 'naw yark', + fuzzy: object( + maxEdits: 1, + prefixLength: 2, + ), + ), + ), + Stage::limit(8), + Stage::project( + _id: 1, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextFuzzyPrefixLength, $pipeline); + } + + public function testMatchAllUsingSynonyms(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: 'plot', + query: 'automobile race', + matchCriteria: 'all', + synonyms: 'my_synonyms', + ), + ), + Stage::limit(20), + Stage::project( + _id: 0, + plot: 1, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextMatchAllUsingSynonyms, $pipeline); + } + + public function testMatchAnyUsingEquivalentMapping(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: 'plot', + query: 'attire', + synonyms: 'my_synonyms', + matchCriteria: 'any', + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + plot: 1, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextMatchAnyUsingEquivalentMapping, $pipeline); + } + + public function testMatchAnyUsingExplicitMapping(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: 'plot', + query: 'boat race', + synonyms: 'my_synonyms', + matchCriteria: 'any', + ), + ), + Stage::limit(10), + Stage::project( + _id: 0, + plot: 1, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextMatchAnyUsingExplicitMapping, $pipeline); + } + + public function testWildcardPath(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::text( + path: ['wildcard' => '*'], + query: 'surfer', + ), + ), + Stage::project( + _id: 0, + title: 1, + score: ['$meta' => 'searchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::TextWildcardPath, $pipeline); + } +} diff --git a/tests/Builder/Search/WildcardOperatorTest.php b/tests/Builder/Search/WildcardOperatorTest.php new file mode 100644 index 000000000..18103b75d --- /dev/null +++ b/tests/Builder/Search/WildcardOperatorTest.php @@ -0,0 +1,54 @@ +assertSamePipeline(Pipelines::WildcardEscapeCharacterExample, $pipeline); + } + + public function testWildcardPath(): void + { + $pipeline = new Pipeline( + Stage::search( + Search::wildcard( + query: 'Wom?n *', + path: ['wildcard' => '*'], + ), + ), + Stage::limit(5), + Stage::project( + _id: 0, + title: 1, + ), + ); + + $this->assertSamePipeline(Pipelines::WildcardWildcardPath, $pipeline); + } +} diff --git a/tests/Builder/Stage/Pipelines.php b/tests/Builder/Stage/Pipelines.php index 8b76342ba..850013c3e 100644 --- a/tests/Builder/Stage/Pipelines.php +++ b/tests/Builder/Stage/Pipelines.php @@ -2638,6 +2638,197 @@ enum Pipelines: string ] JSON; + /** + * Year Facet + * + * @see https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-1 + */ + case SearchMetaYearFacet = <<<'JSON' + [ + { + "$searchMeta": { + "facet": { + "operator": { + "range": { + "path": "year", + "gte": { + "$numberInt": "1980" + }, + "lte": { + "$numberInt": "2000" + } + } + }, + "facets": { + "yearFacet": { + "type": "number", + "path": "year", + "boundaries": [ + { + "$numberInt": "1980" + }, + { + "$numberInt": "1990" + }, + { + "$numberInt": "2000" + } + ], + "default": "other" + } + } + } + } + } + ] + JSON; + + /** + * Date Facet + * + * @see https://www.mongodb.com/docs/atlas/atlas-search/facet/#example-2 + */ + case SearchMetaDateFacet = <<<'JSON' + [ + { + "$searchMeta": { + "facet": { + "operator": { + "range": { + "path": "released", + "gte": { + "$date": { + "$numberLong": "946684800000" + } + }, + "lte": { + "$date": { + "$numberLong": "1422662400000" + } + } + } + }, + "facets": { + "yearFacet": { + "type": "date", + "path": "released", + "boundaries": [ + { + "$date": { + "$numberLong": "946684800000" + } + }, + { + "$date": { + "$numberLong": "1104537600000" + } + }, + { + "$date": { + "$numberLong": "1262304000000" + } + }, + { + "$date": { + "$numberLong": "1420070400000" + } + } + ], + "default": "other" + } + } + } + } + } + ] + JSON; + + /** + * Metadata Results + * + * @see https://www.mongodb.com/docs/atlas/atlas-search/facet/#examples + */ + case SearchMetaMetadataResults = <<<'JSON' + [ + { + "$searchMeta": { + "facet": { + "operator": { + "range": { + "path": "released", + "gte": { + "$date": { + "$numberLong": "946684800000" + } + }, + "lte": { + "$date": { + "$numberLong": "1422662400000" + } + } + } + }, + "facets": { + "directorsFacet": { + "type": "string", + "path": "directors", + "numBuckets": { + "$numberInt": "7" + } + }, + "yearFacet": { + "type": "number", + "path": "year", + "boundaries": [ + { + "$numberInt": "2000" + }, + { + "$numberInt": "2005" + }, + { + "$numberInt": "2010" + }, + { + "$numberInt": "2015" + } + ] + } + } + } + } + } + ] + JSON; + + /** + * Autocomplete Bucket Results through Facet Queries + * + * @see https://www.mongodb.com/docs/atlas/atlas-search/autocomplete/#bucket-results-through-facet-queries + */ + case SearchMetaAutocompleteBucketResultsThroughFacetQueries = <<<'JSON' + [ + { + "$searchMeta": { + "facet": { + "operator": { + "autocomplete": { + "path": "title", + "query": "Gravity" + } + }, + "facets": { + "titleFacet": { + "type": "string", + "path": "title" + } + } + } + } + } + ] + JSON; + /** * Using Two $set Stages * @@ -3362,4 +3553,163 @@ enum Pipelines: string } ] JSON; + + /** + * ANN Basic + * + * @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples + */ + case VectorSearchANNBasic = <<<'JSON' + [ + { + "$vectorSearch": { + "index": "vector_index", + "path": "plot_embedding", + "queryVector": [ + { + "$numberDouble": "-0.0016261311999999999121" + }, + { + "$numberDouble": "-0.028070756999999998266" + }, + { + "$numberDouble": "-0.011342932000000000015" + } + ], + "numCandidates": { + "$numberInt": "150" + }, + "limit": { + "$numberInt": "10" + } + } + }, + { + "$project": { + "_id": { + "$numberInt": "0" + }, + "plot": { + "$numberInt": "1" + }, + "title": { + "$numberInt": "1" + }, + "score": { + "$meta": "vectorSearchScore" + } + } + } + ] + JSON; + + /** + * ANN Filter + * + * @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#ann-examples + */ + case VectorSearchANNFilter = <<<'JSON' + [ + { + "$vectorSearch": { + "index": "vector_index", + "path": "plot_embedding", + "filter": { + "$and": [ + { + "year": { + "$lt": { + "$numberInt": "1975" + } + } + } + ] + }, + "queryVector": [ + { + "$numberDouble": "0.024210530000000000939" + }, + { + "$numberDouble": "-0.022372592000000000173" + }, + { + "$numberDouble": "-0.0062311370000000003075" + } + ], + "numCandidates": { + "$numberInt": "150" + }, + "limit": { + "$numberInt": "10" + } + } + }, + { + "$project": { + "_id": { + "$numberInt": "0" + }, + "title": { + "$numberInt": "1" + }, + "plot": { + "$numberInt": "1" + }, + "year": { + "$numberInt": "1" + }, + "score": { + "$meta": "vectorSearchScore" + } + } + } + ] + JSON; + + /** + * ENN + * + * @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#enn-examples + */ + case VectorSearchENN = <<<'JSON' + [ + { + "$vectorSearch": { + "index": "vector_index", + "path": "plot_embedding", + "queryVector": [ + { + "$numberDouble": "-0.0069540970000000002296" + }, + { + "$numberDouble": "-0.009932498999999999148" + }, + { + "$numberDouble": "-0.0013114739999999999731" + } + ], + "exact": true, + "limit": { + "$numberInt": "10" + } + } + }, + { + "$project": { + "_id": { + "$numberInt": "0" + }, + "plot": { + "$numberInt": "1" + }, + "title": { + "$numberInt": "1" + }, + "score": { + "$meta": "vectorSearchScore" + } + } + } + ] + JSON; } diff --git a/tests/Builder/Stage/SearchMetaStageTest.php b/tests/Builder/Stage/SearchMetaStageTest.php index 3b8283424..6ded31935 100644 --- a/tests/Builder/Stage/SearchMetaStageTest.php +++ b/tests/Builder/Stage/SearchMetaStageTest.php @@ -4,7 +4,10 @@ namespace MongoDB\Tests\Builder\Stage; +use DateTimeImmutable; +use MongoDB\BSON\UTCDateTime; use MongoDB\Builder\Pipeline; +use MongoDB\Builder\Search; use MongoDB\Builder\Stage; use MongoDB\Tests\Builder\PipelineTestCase; @@ -15,19 +18,134 @@ */ class SearchMetaStageTest extends PipelineTestCase { + public function testAutocompleteBucketResultsThroughFacetQueries(): void + { + $pipeline = new Pipeline( + Stage::searchMeta( + Search::facet( + facets: object( + titleFacet: object( + type: 'string', + path: 'title', + ), + ), + operator: Search::autocomplete( + path: 'title', + query: 'Gravity', + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::SearchMetaAutocompleteBucketResultsThroughFacetQueries, $pipeline); + } + + public function testDateFacet(): void + { + $pipeline = new Pipeline( + Stage::searchMeta( + Search::facet( + operator: Search::range( + path: 'released', + gte: new UTCDateTime(new DateTimeImmutable('2000-01-01')), + lte: new UTCDateTime(new DateTimeImmutable('2015-01-31')), + ), + facets: object( + yearFacet: object( + type: 'date', + path: 'released', + boundaries: [ + new UTCDateTime(new DateTimeImmutable('2000-01-01')), + new UTCDateTime(new DateTimeImmutable('2005-01-01')), + new UTCDateTime(new DateTimeImmutable('2010-01-01')), + new UTCDateTime(new DateTimeImmutable('2015-01-01')), + ], + default: 'other', + ), + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::SearchMetaDateFacet, $pipeline); + } + public function testExample(): void { $pipeline = new Pipeline( - Stage::searchMeta(object( - range: object( + Stage::searchMeta( + Search::range( path: 'year', gte: 1998, lt: 1999, ), count: object(type: 'total'), - )), + ), ); $this->assertSamePipeline(Pipelines::SearchMetaExample, $pipeline); } + + public function testMetadataResults(): void + { + $pipeline = new Pipeline( + Stage::searchMeta( + Search::facet( + operator: Search::range( + path: 'released', + gte: new UTCDateTime(new DateTimeImmutable('2000-01-01')), + lte: new UTCDateTime(new DateTimeImmutable('2015-01-31')), + ), + facets: object( + directorsFacet: object( + type: 'string', + path: 'directors', + numBuckets: 7, + ), + yearFacet: object( + type: 'number', + path: 'year', + boundaries: [ + 2000, + 2005, + 2010, + 2015, + ], + ), + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::SearchMetaMetadataResults, $pipeline); + } + + public function testYearFacet(): void + { + $pipeline = new Pipeline( + Stage::searchMeta( + Search::facet( + operator: Search::range( + path: 'year', + gte: 1980, + lte: 2000, + ), + facets: object( + yearFacet: object( + type: 'number', + path: 'year', + boundaries: [ + 1980, + 1990, + 2000, + ], + default: 'other', + ), + ), + ), + ), + ); + + $this->assertSamePipeline(Pipelines::SearchMetaYearFacet, $pipeline); + } } diff --git a/tests/Builder/Stage/SearchStageTest.php b/tests/Builder/Stage/SearchStageTest.php index 656b9b9ee..faae2ab11 100644 --- a/tests/Builder/Stage/SearchStageTest.php +++ b/tests/Builder/Stage/SearchStageTest.php @@ -8,11 +8,10 @@ use MongoDB\BSON\UTCDateTime; use MongoDB\Builder\Expression; use MongoDB\Builder\Pipeline; +use MongoDB\Builder\Search; use MongoDB\Builder\Stage; use MongoDB\Tests\Builder\PipelineTestCase; -use function MongoDB\object; - /** * Test $search stage */ @@ -21,13 +20,13 @@ class SearchStageTest extends PipelineTestCase public function testExample(): void { $pipeline = new Pipeline( - Stage::search(object( - near: object( + Stage::search( + Search::near( path: 'released', origin: new UTCDateTime(new DateTime('2011-09-01T00:00:00.000+00:00')), pivot: 7776000000, ), - )), + ), Stage::project(_id: 0, title: 1, released: 1), Stage::limit(5), Stage::facet( diff --git a/tests/Builder/Stage/VectorSearchStageTest.php b/tests/Builder/Stage/VectorSearchStageTest.php new file mode 100644 index 000000000..f6259510a --- /dev/null +++ b/tests/Builder/Stage/VectorSearchStageTest.php @@ -0,0 +1,85 @@ + 'vectorSearchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::VectorSearchANNBasic, $pipeline); + } + + public function testANNFilter(): void + { + $pipeline = new Pipeline( + Stage::vectorSearch( + index: 'vector_index', + limit: 10, + path: 'plot_embedding', + queryVector: [0.02421053, -0.022372592, -0.006231137], + filter: Query::and( + Query::query( + year: Query::lt(1975), + ), + ), + numCandidates: 150, + ), + Stage::project( + _id: 0, + title: 1, + plot: 1, + year: 1, + score: ['$meta' => 'vectorSearchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::VectorSearchANNFilter, $pipeline); + } + + public function testENN(): void + { + $pipeline = new Pipeline( + Stage::vectorSearch( + index: 'vector_index', + limit: 10, + path: 'plot_embedding', + queryVector: [-0.006954097, -0.009932499, -0.001311474], + exact: true, + ), + Stage::project( + _id: 0, + title: 1, + plot: 1, + score: ['$meta' => 'vectorSearchScore'], + ), + ); + + $this->assertSamePipeline(Pipelines::VectorSearchENN, $pipeline); + } +}