psalm / psalm-plugin-symfony

Psalm Plugin for Symfony
MIT License
228 stars 53 forks source link

Console: Wrong type for required argument value #303

Closed gharlan closed 1 year ago

gharlan commented 1 year ago

This works:

    protected function configure()
    {
        $this ->addArgument('myarg', InputArgument::REQUIRED, 'description');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        /** @psalm-trace $myarg */
        $myarg = $input->getArgument('myarg');

type of $myarg is string. 👍

But when I add suggestions to the argument:

        $this ->addArgument('myarg', InputArgument::REQUIRED, 'description', null, ['my', 'suggestions']);

then the type of $myarg is null|string, which is wrong. For InputArgument::REQUIRED the given default value should be ignored.