| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public static function updateField(&$data, $value, string $rule, string $fieldName) : void |
||
| 28 | { |
||
| 29 | $current = $data[$fieldName]; |
||
| 30 | switch ($rule) { |
||
| 31 | case 'set:': |
||
| 32 | $data[$fieldName] = $value; |
||
| 33 | break; |
||
| 34 | case 'sum:': |
||
| 35 | $data[$fieldName] = ($current ?? 0) + $value; |
||
| 36 | break; |
||
| 37 | case 'max:': |
||
| 38 | $data[$fieldName] = max([$current, $value]); |
||
| 39 | break; |
||
| 40 | case 'min:': |
||
| 41 | $data[$fieldName] = min([$current, $value]); |
||
| 42 | break; |
||
| 43 | default: |
||
| 44 | throw new \Exception('Unknown type '.$rule); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.