| Conditions | 5 |
| Paths | 5 |
| Total Lines | 29 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | function patch_composer_json(): void |
||
| 6 | { |
||
| 7 | if (!file_exists('symfony/composer.json')) { |
||
| 8 | echo 'symfony/composer.json not found!'.PHP_EOL; |
||
| 9 | exit(-1); |
||
|
|
|||
| 10 | } |
||
| 11 | |||
| 12 | $contents = file_get_contents('symfony/composer.json'); |
||
| 13 | if ($contents === false) { |
||
| 14 | exit(-1); |
||
| 15 | } |
||
| 16 | |||
| 17 | $json = json_decode($contents, true); |
||
| 18 | $json['repositories'] = [[ |
||
| 19 | 'type' => 'path', |
||
| 20 | 'url' => '../', |
||
| 21 | ]]; |
||
| 22 | $json['require']['artprima/prometheus-metrics-bundle'] = '*'; |
||
| 23 | $json['require-dev'] = (object)$json['require-dev']; |
||
| 24 | $json['minimum-stability'] = 'dev'; |
||
| 25 | $json['prefer-stable'] = true; |
||
| 26 | $data = json_encode($json, JSON_PRETTY_PRINT); |
||
| 27 | if ($data === false) { |
||
| 28 | exit(-1); |
||
| 29 | } |
||
| 30 | |||
| 31 | $result = file_put_contents('symfony/composer.json', $data); |
||
| 32 | if ($result === false) { |
||
| 33 | exit(-1); |
||
| 34 | } |
||
| 38 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.