Description
Symfony version(s) affected: 3.4.16 (and master from the look of it)
Description
getArgument
changed (here symfony/console@b6c275e) the return type from mixed
to string|string[]
, but if I don't set a default value in '->addArgument()it returns
null. (I guess I could also set that default value to
falseor anything else, it's defined as
mixed` in the doctype).
Now phpstan for example complains about that, when I check for null in my code to see, if it's set or not.
Is it wrong to check for "no argument set" in that way? What's the official way then?
How to reproduce
set up a command with
->addArgument(
'prefix',
InputArgument::OPTIONAL,
'Table prefix (optional)'
)
check for that
if (null !== $input->getArgument('prefix')) {
// do something
}
and phpstan will complain
Possible Solution
expand the doctype to be able to return "null" or don't accept anything else as a defaultValue than a string (and make the default eg. '', but I guess, that would break some BC)