The definition docblocks promise a default key and type casting:
Definitions keyed by position, each with optional "type", "required" and "default" keys
(src/Command.php:56-58)
Values declared with a type are cast when possible
(src/Command.php:326-327)
Neither happens. validateDefinitions() only reports errors, and nothing ever writes back into Console::$arguments or Console::$options.
protected array $argumentDefinitions = [1 => ['type' => 'string', 'default' => 'fallback']];
protected array $optionDefinitions = ['name' => ['type' => 'string', 'default' => 'anon']];
php app typed 5
# getArgument(1) === null (expected 'fallback')
# getOption('name') === null (expected 'anon')
Verified on PHP 8.4.19 against main (2c0159f).
Two ways out: implement defaults and casting so getArgument()/getOption() return the resolved value, or drop both claims from the docblocks. Implementing them is the more useful option, since it is what the definitions API implies. Casting also raises a design question worth settling here: getArgument() is typed ?string, so an int definition cannot return an int without a signature change or a separate typed accessor.
The definition docblocks promise a
defaultkey and type casting:Neither happens.
validateDefinitions()only reports errors, and nothing ever writes back intoConsole::$argumentsorConsole::$options.Verified on PHP 8.4.19 against main (2c0159f).
Two ways out: implement defaults and casting so
getArgument()/getOption()return the resolved value, or drop both claims from the docblocks. Implementing them is the more useful option, since it is what the definitions API implies. Casting also raises a design question worth settling here:getArgument()is typed?string, so anintdefinition cannot return an int without a signature change or a separate typed accessor.