Console::run() handles -h/--help by instantiating the built in Help command directly and letting it read argument 0 as the command name (src/Console.php:289-292, src/Commands/Help.php:28-35). Three problems follow.
1. --help fails on any command that takes arguments. Argument 0 is used as the command name even when it is a value:
php app deploy prod --help
# Command not found: "prod" (exit 1)
2. A registered custom help command is ignored. new Help($this) skips the command registry, so $console->addCommand(new MyHelp($console)) is honoured by php app help deploy but not by php app deploy --help.
3. -h is globally reserved. A command that documents -h for its own use can never receive it:
protected array $options = ['-h, --host' => 'The host to bind.'];
// php app serve -h 0.0.0.0 -> Command not found: "0.0.0.0"
Verified on PHP 8.4.19 against main (2c0159f).
Suggested fix: resolve help through getCommand('help') so overrides work, and only treat argument 0 as a target when it actually names a registered command, otherwise fall back to the current command name. Point 3 needs a decision: either let a command opt out of the global -h, or reserve only the long --help.
Console::run()handles-h/--helpby instantiating the built in Help command directly and letting it read argument 0 as the command name (src/Console.php:289-292,src/Commands/Help.php:28-35). Three problems follow.1.
--helpfails on any command that takes arguments. Argument 0 is used as the command name even when it is a value:php app deploy prod --help # Command not found: "prod" (exit 1)2. A registered custom help command is ignored.
new Help($this)skips the command registry, so$console->addCommand(new MyHelp($console))is honoured byphp app help deploybut not byphp app deploy --help.3.
-his globally reserved. A command that documents-hfor its own use can never receive it:Verified on PHP 8.4.19 against main (2c0159f).
Suggested fix: resolve help through
getCommand('help')so overrides work, and only treat argument 0 as a target when it actually names a registered command, otherwise fall back to the current command name. Point 3 needs a decision: either let a command opt out of the global-h, or reserve only the long--help.