Closed
Description
In the interact
method of the symfony console command its possible to ask for required attributes. In that context a required argument can still be null.
The following code will tell that the null check does not work:
e.g.:
protected function configure(): void
{
$this->addArgument('market', InputArgument::REQUIRED);
}
protected function interact(InputInterface $input, OutputInterface $output): void
{
$market = $input->getArgument('market'); // here market can still be `null|string`
if ($market === null) {
$input->setArgument('market', $ui->ask('Which market you want to use for the import?'));
}
}
protected function execute(InputInterface $input, OutputInterface $output): void
{
$market = $input->getArgument('market'); // here market can only be a string
}
When using !$market
rector will actually refractor it to $test === '' && $test === '0'
so that is also not correct.
If possible it would be great that depending if the argument is used inside interact it should be nullable else it should be the same as currently. Not sure if that is possible via phpstan.
Metadata
Metadata
Assignees
Labels
No labels