An option passed without a value is parsed as true. Command::validateDefinitions() skips any value that is not a string (src/Command.php:367), so a typed option silently passes validation and the command receives a bool where it expects a numeric string.
protected array $optionDefinitions = [
'limit' => ['type' => 'int'],
];
php app typed 5 --limit
# no validation error
# $console->getOption('limit') === true
Verified on PHP 8.4.19 against main (2c0159f).
Expected: when a definition declares a type other than the implicit string, an option given without a value should fail validation with something like option "limit" must be of type int.. A definition may also want a way to say the option is a flag, so true stays valid for flags only.
An option passed without a value is parsed as
true.Command::validateDefinitions()skips any value that is not a string (src/Command.php:367), so a typed option silently passes validation and the command receives a bool where it expects a numeric string.Verified on PHP 8.4.19 against main (2c0159f).
Expected: when a definition declares a type other than the implicit
string, an option given without a value should fail validation with something likeoption "limit" must be of type int.. A definition may also want a way to say the option is a flag, sotruestays valid for flags only.