1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
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); |
||
0 ignored issues
–
show
|
|||
10 | } |
||
11 | |||
12 | $contents = file_get_contents('symfony/composer.json'); |
||
13 | if ($contents === false) { |
||
14 | exit(-1); |
||
0 ignored issues
–
show
|
|||
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); |
||
0 ignored issues
–
show
|
|||
29 | } |
||
30 | |||
31 | $result = file_put_contents('symfony/composer.json', $data); |
||
32 | if ($result === false) { |
||
33 | exit(-1); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | } |
||
36 | |||
37 | patch_composer_json(); |
||
38 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.