From 181bef236f0c54621d0ffdc5d5b20858d8af2761 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 19 Jan 2024 10:27:50 +0100 Subject: [PATCH] Show help for --manifest, --sbom, and --composer-lock when the PHAR is used --- src/TextUI/Help.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/TextUI/Help.php b/src/TextUI/Help.php index 7a2c3a75123..519d4fbd347 100644 --- a/src/TextUI/Help.php +++ b/src/TextUI/Help.php @@ -11,6 +11,7 @@ use const PHP_EOL; use function count; +use function defined; use function explode; use function max; use function preg_replace_callback; @@ -149,7 +150,7 @@ static function ($matches) */ private function elements(): array { - return [ + $elements = [ 'Usage' => [ ['text' => 'phpunit [options] UnitTest [UnitTest.php]'], ['text' => 'phpunit [options] '], @@ -250,13 +251,23 @@ private function elements(): array ['arg' => '--generate-configuration', 'desc' => 'Generate configuration file with suggested settings'], ['arg' => '--cache-result-file=', 'desc' => 'Specify result cache path and filename'], ], + ]; - 'Miscellaneous Options' => [ - ['arg' => '-h|--help', 'desc' => 'Prints this usage information'], - ['arg' => '--version', 'desc' => 'Prints the version and exits'], - ['arg' => '--atleast-version ', 'desc' => 'Checks that version is greater than min and exits'], - ['arg' => '--check-version', 'desc' => 'Check whether PHPUnit is the latest version'], - ], + if (defined('__PHPUNIT_PHAR__')) { + $elements['PHAR Options'] = [ + ['arg' => '--manifest', 'desc' => 'Print Software Bill of Materials (SBOM) in plain-text format'], + ['arg' => '--sbom', 'desc' => 'Print Software Bill of Materials (SBOM) in CycloneDX XML format'], + ['arg' => '--composer-lock', 'desc' => 'Print composer.lock file used to build the PHAR'], + ]; + } + + $elements['Miscellaneous Options'] = [ + ['arg' => '-h|--help', 'desc' => 'Prints this usage information'], + ['arg' => '--version', 'desc' => 'Prints the version and exits'], + ['arg' => '--atleast-version ', 'desc' => 'Checks that version is greater than min and exits'], + ['arg' => '--check-version', 'desc' => 'Check whether PHPUnit is the latest version'], ]; + + return $elements; } }