phpstan / phpstan-symfony

Symfony extension for PHPStan
MIT License
698 stars 89 forks source link

Improve Command::initialize and `command` argument inferences #398

Closed VincentLanglet closed 2 months ago

VincentLanglet commented 2 months ago

This follow the same idea of https://github.com/phpstan/phpstan-symfony/pull/391.

When looking at the execute method of the Symfony command https://github.com/symfony/symfony/blob/c0e30bb06bb4c12efc8bad13f7cb732954cb0182/src/Symfony/Component/Console/Command/Command.php#L231-L280

The order of the call are

$this->initialize($input, $output);
$this->interact($input, $output);
if ($input->hasArgument('command') && null === $input->getArgument('command')) {
     $input->setArgument('command', $this->getName());
}
$input->validate();
$this->execute($input, $output);

Which means that:

ondrejmirtes commented 2 months ago

Thank you.