Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPLIB-1598 Use named types for enums #1570

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generator/config/accumulator/bottom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- sortBy
description: |
Specifies the order of results, with syntax similar to $sort.
-
Expand Down
2 changes: 1 addition & 1 deletion generator/config/accumulator/bottomN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- sortBy
description: |
Specifies the order of results, with syntax similar to $sort.
-
Expand Down
2 changes: 1 addition & 1 deletion generator/config/accumulator/median.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ arguments:
-
name: method
type:
- string # AccumulatorPercentile
- accumulatorPercentile
description: |
The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'.
tests:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/accumulator/percentile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ arguments:
-
name: method
type:
- string # AccumulatorPercentile
- accumulatorPercentile
description: |
The method that mongod uses to calculate the percentile value. The method must be 'approximate'.
tests:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/accumulator/top.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- sortBy
description: |
Specifies the order of results, with syntax similar to $sort.
-
Expand Down
2 changes: 1 addition & 1 deletion generator/config/accumulator/topN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- sortBy
description: |
Specifies the order of results, with syntax similar to $sort.
-
Expand Down
2 changes: 1 addition & 1 deletion generator/config/expression/median.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ arguments:
-
name: method
type:
- string # AccumulatorPercentile
- accumulatorPercentile
description: |
The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'.
tests:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/expression/percentile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ arguments:
-
name: method
type:
- string # AccumulatorPercentile
- accumulatorPercentile
description: |
The method that mongod uses to calculate the percentile value. The method must be 'approximate'.
tests:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/expression/sortArray.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- int
- sortSpec
- sortBy
description: |
The document specifies a sort ordering.
tests:
Expand Down
29 changes: 10 additions & 19 deletions generator/config/expressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,45 +131,36 @@
],

// @todo add enum values
'Granularity' => [
'granularity' => [
'acceptedTypes' => [...$bsonTypes['string']],
],
'FullDocument' => [
'fullDocument' => [
'acceptedTypes' => [...$bsonTypes['string']],
],
'FullDocumentBeforeChange' => [
'fullDocumentBeforeChange' => [
'acceptedTypes' => [...$bsonTypes['string']],
],
'AccumulatorPercentile' => [
'accumulatorPercentile' => [
'acceptedTypes' => [...$bsonTypes['string']],
],
'WhenMatched' => [
'whenMatched' => [
'acceptedTypes' => [...$bsonTypes['string']],
],
'WhenNotMatched' => [
'whenNotMatched' => [
'acceptedTypes' => [...$bsonTypes['string']],
],

// @todo create specific model classes factories
'OutCollection' => [
'outCollection' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'CollStats' => [
'range' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'Range' => [
'sortBy' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'FillOut' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'SortSpec' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'Window' => [
'acceptedTypes' => [...$bsonTypes['object']],
],
'GeoPoint' => [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm that "FillOut", "Window", and "GeoPoint" were never used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they were used, the generator would fail.

'geoPoint' => [
'acceptedTypes' => [...$bsonTypes['object']],
],

Expand Down
12 changes: 11 additions & 1 deletion generator/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": {
"$comment": "The name of the operator. Must start with a $",
"type": "string",
"pattern": "^\\$[a-z0-9][a-zA-Z0-9]*$"
"pattern": "^\\$?[a-z][a-zA-Z0-9]*$"
},
"link": {
"$comment": "The link to the operator's documentation on MongoDB's website.",
Expand Down Expand Up @@ -122,6 +122,16 @@
"timeUnit",
"sortSpec",
"any",
"granularity",
"fullDocument",
"fullDocumentBeforeChange",
"accumulatorPercentile",
"whenMatched",
"whenNotMatched",
"outCollection",
"range",
"sortBy",
"geoPoint",
"resolvesToNumber", "numberFieldPath", "number",
"resolvesToDouble", "doubleFieldPath", "double",
"resolvesToString", "stringFieldPath", "string",
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/bucketAuto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ arguments:
-
name: granularity
type:
- object # Granularity
- granularity
optional: true
description: |
A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10.
Expand Down
4 changes: 2 additions & 2 deletions generator/config/stage/changeStream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ arguments:
-
name: fullDocument
type:
- string # FullDocument
- fullDocument
optional: true
description: |
Specifies whether change notifications include a copy of the full document when modified by update operations.
-
name: fullDocumentBeforeChange
type:
- string # FullDocumentBeforeChange
- fullDocumentBeforeChange
optional: true
description: |
Valid values are "off", "whenAvailable", or "required". If set to "off", the "fullDocumentBeforeChange" field of the output document is always omitted. If set to "whenAvailable", the "fullDocumentBeforeChange" field will be populated with the pre-image of the document modified by the current change event if such a pre-image is available, and will be omitted otherwise. If set to "required", then the "fullDocumentBeforeChange" field is always populated and an exception is thrown if the pre-image is not available.
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/densify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ arguments:
-
name: range
type:
- object # Range
- range
description: |
Specification for range based densification.
tests:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/fill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- sortBy
optional: true
description: |
Specifies the field or fields to sort the documents within each partition. Uses the same syntax as the $sort stage.
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/geoNear.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ arguments:
-
name: near
type:
- object # GeoPoint
- geoPoint
- resolvesToObject
description: |
The point for which to find the closest documents.
Expand Down
6 changes: 3 additions & 3 deletions generator/config/stage/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ arguments:
name: into
type:
- string
- object # OutCollection
- outCollection
description: |
The output collection.
-
Expand All @@ -33,15 +33,15 @@ arguments:
-
name: whenMatched
type:
- string # WhenMatched
- whenMatched
- pipeline
optional: true
description: |
The behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).
-
name: whenNotMatched
type:
- string # WhenNotMatched
- whenNotMatched
optional: true
description: |
The behavior of $merge if a result document does not match an existing document in the out collection.
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ arguments:
- name: coll
type:
- string
- object # OutCollection
- outCollection
description: |
Target database name to write documents from $out to.
tests:
Expand Down
2 changes: 1 addition & 1 deletion generator/config/stage/setWindowFields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ arguments:
-
name: sortBy
type:
- object # SortSpec
- sortBy
description: |
Specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting.
-
Expand Down
8 changes: 4 additions & 4 deletions src/Builder/Stage/BucketAutoStage.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Builder/Stage/FactoryTrait.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Builder/Stage/FluentFactoryTrait.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.