From 0d6ba87154a4d84daa62d9186372497ccc850533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 2 Dec 2024 21:33:24 +0100 Subject: [PATCH] Wording --- generator/README.md | 23 ++++++++++++----------- src/Builder/Encoder/OperatorEncoder.php | 2 ++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/generator/README.md b/generator/README.md index 92ba1cd96..3e18976f9 100644 --- a/generator/README.md +++ b/generator/README.md @@ -19,17 +19,18 @@ The `generator/config/*.yaml` files contains the list of operators and stages th ### Arguments -| Field | Type | Description | -| `name` | `string` | The name of the argument. It can start with `$` when the aggregation operator needs it, but it will be 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. | +| 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 diff --git a/src/Builder/Encoder/OperatorEncoder.php b/src/Builder/Encoder/OperatorEncoder.php index 192d30740..4996c7c3f 100644 --- a/src/Builder/Encoder/OperatorEncoder.php +++ b/src/Builder/Encoder/OperatorEncoder.php @@ -74,6 +74,8 @@ private function encodeAsObject(OperatorInterface $value): stdClass continue; } + // 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) {