phpstan/phpstan-symfony

wrong asumption about `InputInterface::getArgument()` return type in `interact()`

Closed this issue · 5 comments

Hello,

since this PR, if the config symfony.consoleApplicationLoader is not provided, PHPStan will always consider that every call to $input->getArgument() inside the method interfact() will return null.

Maybe some guard condition should be added gefore adding NullType.

I'm willing to fix this if you think it is relevant

PHPStan will always consider that every call to $input->getArgument() inside the method interfact() will return null.

Maybe some guard condition should be added gefore adding NullType.

I made some new tries and

$this->addArgument('task', InputArgument::REQUIRED); // Possibly null in interact
$this->addArgument('task', InputArgument::REQUIRED | InputArgument::ARRAY); // [] in interact
$this->addArgument('task', InputArgument::REQUIRED, default: 'foo'); // Not possible
$this->addArgument('task', InputArgument::OPTIONAL); // Possibly null in interact
$this->addArgument('task', InputArgument::OPTIONAL, default: 'foo'); // Not null in interact

And also, indeed, we need to add Null only if some types were already inferred.

I opened #397

Please test 1.4.4 https://github.com/phpstan/phpstan-symfony/releases/tag/1.4.4 to see whether it fixes your problem.

problem fixed ✔️

thanks!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.