| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | protected function wrapGlobal(array $body): array |
||
| 12 | { |
||
| 13 | $nested = $body['aggs'][$this->name]; |
||
|
|
|||
| 14 | |||
| 15 | if (!isset($body['aggs']['global'])) { |
||
| 16 | $body['aggs']['global'] = []; |
||
| 17 | } |
||
| 18 | |||
| 19 | $body['aggs']['global'] = array_merge_recursive((array) $body['aggs']['global'], [ |
||
| 20 | 'aggs' => [$this->name => $nested] |
||
| 21 | ]); |
||
| 22 | |||
| 23 | // this field MUST NOT be array |
||
| 24 | $body['aggs']['global']['global'] = (object) []; |
||
| 25 | |||
| 26 | return $body; |
||
| 27 | } |
||
| 28 | } |
||
| 29 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: