From cd9c51f29b8b185e129a19c0dcd2a217b114ea48 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 5 Nov 2026 20:59:40 +0800 Subject: [PATCH] fix: drop extra arguments when `--help` is passed --- system/CLI/Console.php | 2 +- tests/system/CLI/ConsoleTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/system/CLI/Console.php b/system/CLI/Console.php index 1994dbedb8e7..45a393946f7b 100644 --- a/system/CLI/Console.php +++ b/system/CLI/Console.php @@ -128,7 +128,7 @@ private function dispatch(Output $output, array $arguments): int if ($arguments === []) { $arguments = ['help', self::DEFAULT_COMMAND]; } elseif ($arguments[0] !== 'help') { - array_unshift($arguments, 'help'); + $arguments = ['help', $arguments[0]]; } // Options supplied alongside --help were meant for the target command, diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index d36fd5285447..0a99a7daf753 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -411,6 +411,15 @@ public function testHelpShortcutStripsOptionsMeantForTargetCommand(): void $this->assertStringContainsString('serve [options]', $this->getStreamFilterBuffer()); } + public function testHelpOptionStripsArgumentsMeantForTargetCommand(): void + { + $this->initializeConsole('env', 'production', '--help'); + $exitCode = (new Console())->run(); + + $this->assertSame(EXIT_SUCCESS, $exitCode); + $this->assertStringContainsString('env [options] [--] []', $this->getStreamFilterBuffer()); + } + public function testHelpArgumentAndHelpOptionCombined(): void { $this->initializeConsole('help', '--help');