psalm-plugin-symfony icon indicating copy to clipboard operation
psalm-plugin-symfony copied to clipboard

Symfony 6 InputBag Stub

Open natewiebe13 opened this issue 3 years ago • 2 comments

Related: https://github.com/psalm/psalm-plugin-symfony/pull/235

The changes to the InputBag sub is causing the following error:

ERROR: InvalidArgument - src/Controller/TestController.php:154:132 - Argument 2 of Symfony\Component\HttpFoundation\InputBag::get cannot be false, null|string value expected (see https://psalm.dev/004)

	return (bool)$request->query->get('inline', false);

It looks like @psalm-param D $default is thinking D is null|string where the line above is setting more types. If I replace D with the full string|int|float|bool|null it functions as expected.

natewiebe13 avatar Feb 16 '22 16:02 natewiebe13

Also, it looks like there's duplication going on. null can likely be added to T and D can be removed completely

natewiebe13 avatar Feb 16 '22 16:02 natewiebe13

It looks like if I set the template on the function, rather than the class, it works as expected. Potentially this is a bug with Psalm itself.

natewiebe13 avatar Feb 16 '22 16:02 natewiebe13

@natewiebe13 thanks for the report.

Instead of return (bool)$request->query->get('inline', false); the following should be used:

return $request->query->getBoolean('inline', false);

seferov avatar Oct 25 '22 05:10 seferov