Skip to content

Commit 04d953e

Browse files
committed
Replace getOperator with Operator::NAME constant
1 parent 1074e23 commit 04d953e

File tree

278 files changed

+295
-1363
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

+295
-1363
lines changed

generator/config/expression/case.yaml

+2-1
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

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"enum": [
6161
"array",
6262
"object",
63-
"flat_object",
6463
"dollar_object",
6564
"single",
6665
"group"
@@ -70,6 +69,11 @@
7069
"$comment": "The description of the argument from MongoDB's documentation.",
7170
"type": "string"
7271
},
72+
"noName": {
73+
"$comment": "Don't wrap the properties in an object with the operator name",
74+
"type": "boolean",
75+
"default": false
76+
},
7377
"arguments": {
7478
"$comment": "An optional list of arguments for the operator.",
7579
"type": "array",

generator/src/Definition/OperatorDefinition.php

+1-1
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
'dollar_object' => Encode::DollarObject,
4444
'group' => Encode::Group,
4545
default => throw new UnexpectedValueException(sprintf('Unexpected "encode" value for operator "%s". Got "%s"', $name, $encode)),

generator/src/OperatorClassGenerator.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
6060
$class->addComment('@see ' . $operator->link);
6161
$namespace->addUse(Encode::class);
6262
$class->addConstant('ENCODE', new Literal('Encode::' . $operator->encode->name));
63+
$class->addConstant('NAME', $operator->noName ? null : $operator->name);
6364

6465
$constuctor = $class->addMethod('__construct');
6566
foreach ($operator->arguments as $argument) {
@@ -170,10 +171,6 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
170171
$constuctor->addBody('$this->' . $argument->name . ' = $' . $argument->name . ';');
171172
}
172173

173-
$class->addMethod('getOperator')
174-
->setReturnType('string')
175-
->setBody('return ' . var_export($operator->name, true) . ';');
176-
177174
return $namespace;
178175
}
179176

src/Builder/Accumulator/AccumulatorAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/AddToSetAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/AvgAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/BottomAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/BottomNAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/CountAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/CovariancePopAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/CovarianceSampAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DenseRankAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DerivativeAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/DocumentNumberAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/ExpMovingAvgAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/FirstAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/FirstNAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/IntegralAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LastAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LastNAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LinearFillAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Accumulator/LocfAccumulator.php

+1-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)