1212 exit (1 );
1313}
1414
15- $ dependencies = dependencies ();
15+ $ package = package ();
1616$ version = version ();
17+ $ dependencies = dependencies ();
1718
18- manifest ($ argv [1 ], $ version , $ dependencies );
19- sbom ($ argv [2 ], $ version , $ dependencies );
19+ manifest ($ argv [1 ], $ package , $ version , $ dependencies );
20+ sbom ($ argv [2 ], $ package , $ version , $ dependencies );
2021
21- function manifest (string $ outputFilename , string $ version , array $ dependencies ): void
22+ function manifest (string $ outputFilename , array $ package , string $ version , array $ dependencies ): void
2223{
23- $ buffer = 'phpunit/phpunit: ' . $ version . "\n" ;
24+ $ buffer = sprintf (
25+ '%s/%s: %s ' . "\n" ,
26+ $ package ['group ' ],
27+ $ package ['name ' ],
28+ $ version
29+ );
2430
2531 foreach ($ dependencies as $ dependency ) {
2632 $ buffer .= $ dependency ['name ' ] . ': ' . $ dependency ['version ' ];
@@ -35,7 +41,7 @@ function manifest(string $outputFilename, string $version, array $dependencies):
3541 file_put_contents ($ outputFilename , $ buffer );
3642}
3743
38- function sbom (string $ outputFilename , string $ version , array $ dependencies ): void
44+ function sbom (string $ outputFilename , array $ package , string $ version , array $ dependencies ): void
3945{
4046 $ writer = new XMLWriter ;
4147
@@ -50,11 +56,11 @@ function sbom(string $outputFilename, string $version, array $dependencies): voi
5056
5157 writeComponent (
5258 $ writer ,
53- ' phpunit ' ,
54- ' phpunit ' ,
59+ $ package [ ' group ' ] ,
60+ $ package [ ' name ' ] ,
5561 $ version ,
56- ' The PHP Unit Testing framework ' ,
57- [ ' BSD-3-Clause ' ]
62+ $ package [ ' description ' ] ,
63+ $ package [ ' license ' ]
5864 );
5965
6066 foreach ($ dependencies as $ dependency ) {
@@ -92,6 +98,26 @@ function dependencies(): array
9298 )['packages ' ];
9399}
94100
101+ function package (): array
102+ {
103+ $ data = json_decode (
104+ file_get_contents (
105+ __DIR__ . '/../../composer.json '
106+ ),
107+ true
108+ );
109+
110+ [$ group , $ name ] = explode ('/ ' , $ data ['name ' ]);
111+
112+ return [
113+ 'group ' => $ group ,
114+ 'name ' => $ name ,
115+ 'description ' => $ data ['description ' ],
116+ 'license ' => [$ data ['license ' ]],
117+ 'branch ' => $ data ['extra ' ]['branch-alias ' ]['dev-master ' ]
118+ ];
119+ }
120+
95121function version (): string
96122{
97123 $ tag = @exec ('git describe --tags 2>&1 ' );
0 commit comments