Description
Symfony version(s) affected: 5.1.*
Description
In version 5.1.* the type of $query property in Request class was changed from ParameterBag to InputBag.
InputBag extends ParameterBag but modified method get() signature.
This make the following code (which works fine in 5.0.*) invalid
$languages = $request->query->get('languages', ['en']);
In the project I'm currently working on we use PHPStan which is part of our continuous integration process.
PHPStan throws a lot of warnings because of this inconsistency.
How to reproduce
Run a PHPStan on a file which call $request->query->get() with array as default argument.
Possible Solution
Change Request::query type back to ParameterBag
Additional context
In Symfony 5.0.*
PHPStan error:
Parameter #2 $default of method Symfony\Component\HttpFoundation\InputBag::get() expects string|null, array<int, string> given.
According to the official Symfony 5.1.* documentation the type of query is ParameterBag, not InputBag.
https://symfony.com/doc/current/components/http_foundation.html#accessing-request-data