Skip to content

Commit 1a9db11

Browse files
committed
Replace getOperator with Operator::NAME constant
1 parent 9fc0d42 commit 1a9db11

File tree

278 files changed

+301
-1366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+301
-1366
lines changed

generator/config/expression/case.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: $case
33
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/'
44
type:
55
- switchBranch
6-
encode: flat_object
6+
encode: object
7+
noName: true
78
description: |
89
Represents a single case in a $switch expression
910
arguments:

generator/config/schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@
6060
"enum": [
6161
"array",
6262
"object",
63-
"flat_object",
63+
"dollar_object",
6464
"single"
6565
]
6666
},
6767
"description": {
6868
"$comment": "The description of the argument from MongoDB's documentation.",
6969
"type": "string"
7070
},
71+
"noName": {
72+
"$comment": "Don't wrap the properties in an object with the operator name",
73+
"type": "boolean",
74+
"default": false
75+
},
7176
"arguments": {
7277
"$comment": "An optional list of arguments for the operator.",
7378
"type": "array",

generator/src/Definition/OperatorDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public function __construct(
3232
/** @var list<string> */
3333
public array $type,
3434
public string|null $description = null,
35+
public bool $noName = false,
3536
array $arguments = [],
3637
array $tests = [],
3738
) {
3839
$this->encode = match ($encode) {
3940
'single' => Encode::Single,
4041
'array' => Encode::Array,
4142
'object' => Encode::Object,
42-
'flat_object' => Encode::FlatObject,
4343
default => throw new UnexpectedValueException(sprintf('Unexpected "encode" value for operator "%s". Got "%s"', $name, $encode)),
4444
};
4545

generator/src/OperatorClassGenerator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
6262
$class->addComment('@internal');
6363
$namespace->addUse(Encode::class);
6464
$class->addConstant('ENCODE', new Literal('Encode::' . $operator->encode->name));
65+
$class->addConstant('NAME', $operator->noName ? null : $operator->name);
6566

6667
$encodeNames = [];
6768
$constructor = $class->addMethod('__construct');
@@ -179,10 +180,6 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
179180
$class->addConstant('PROPERTIES', $encodeNames);
180181
}
181182

182-
$class->addMethod('getOperator')
183-
->setReturnType('string')
184-
->setBody('return ' . var_export($operator->name, true) . ';');
185-
186183
return $namespace;
187184
}
188185

src/Builder/Accumulator/AccumulatorAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/AddToSetAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/AvgAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/BottomAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/BottomNAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/CountAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/CovariancePopAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/CovarianceSampAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DenseRankAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DerivativeAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DocumentNumberAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/ExpMovingAvgAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/FirstAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/FirstNAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/IntegralAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LastAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LastNAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LinearFillAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LocfAccumulator.php

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)