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(); ?> +