From fdc88519db469f113e259617917ecc56f8c04eee Mon Sep 17 00:00:00 2001 From: Laurent Laville Date: Thu, 3 Oct 2024 13:17:40 +0000 Subject: [PATCH] default stub for BOX Manifest v4 --- .gitignore | 1 - stub.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 stub.php diff --git a/.gitignore b/.gitignore index 896c602..f4c18a5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ sbom.xml sbom.cdx.json sbom.cdx.xml custom.bin -stub.php ###### PHPLint ###### .phplint-cache diff --git a/stub.php b/stub.php new file mode 100644 index 0000000..7a85791 --- /dev/null +++ b/stub.php @@ -0,0 +1,36 @@ + $withManifest) && !str_starts_with($argv[$withManifest + 1], '-')) ? [$argv[$withManifest + 1]] : ['console-table.txt', 'plain.txt', 'sbom.json']; + + foreach ($resources as $resource) { + $res = str_replace($manifestDir, '', $resource); + $filename = "phar://" . __FILE__ . "/$manifestDir$res"; + if (file_exists($filename)) { + $manifest = file_get_contents($filename); + if ($withoutAnsi !== false) { + $manifest = preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $manifest); + } + echo $manifest, PHP_EOL; + exit(0); + } elseif (count($resources) === 1) { + echo sprintf('Manifest "%s" is not available in this PHP Archive.', $resource), PHP_EOL; + exit(2); + } + } + echo 'No manifest found in this PHP Archive', PHP_EOL; + exit(1); +} + + + +// No PHAR config + +__HALT_COMPILER(); ?> +