File tree Expand file tree Collapse file tree 6 files changed +78
-1
lines changed
stubs/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 6 files changed +78
-1
lines changed Original file line number Diff line number Diff line change 1515 "require" : {
1616 "php" : " ^7.1 || ^8.0" ,
1717 "ext-simplexml" : " *" ,
18- "phpstan/phpstan" : " ^0.12.86 "
18+ "phpstan/phpstan" : " ^0.12.97 "
1919 },
2020 "conflict" : {
2121 "symfony/framework-bundle" : " <3.0"
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ parameters:
44 exceptions :
55 uncheckedExceptionClasses :
66 - 'Symfony\Component\Console\Exception\InvalidArgumentException'
7+ featureToggles :
8+ skipCheckGenericClasses :
9+ - Symfony\Component\HttpFoundation\InputBag
710 symfony :
811 container_xml_path : null
912 constant_hassers : true
@@ -22,7 +25,9 @@ parameters:
2225 - stubs/Symfony/Component/Form/FormView.stub
2326 - stubs/Symfony/Component/HttpFoundation/Cookie.stub
2427 - stubs/Symfony/Component/HttpFoundation/HeaderBag.stub
28+ - stubs/Symfony/Component/HttpFoundation/InputBag.stub
2529 - stubs/Symfony/Component/HttpFoundation/ParameterBag.stub
30+ - stubs/Symfony/Component/HttpFoundation/Request.stub
2631 - stubs/Symfony/Component/HttpFoundation/Session.stub
2732 - stubs/Symfony/Component/Process/Process.stub
2833 - stubs/Symfony/Component/PropertyAccess/PropertyPathInterface.stub
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Symfony\Component\HttpFoundation;
4+
5+ /**
6+ * @template TValue of string|int|float|bool
7+ */
8+ final class InputBag extends ParameterBag
9+ {
10+
11+ /**
12+ * @param TValue|null $default
13+ * @return TValue|null
14+ */
15+ public function get(string $key, $default = null)
16+ {
17+
18+ }
19+
20+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Symfony\Component\HttpFoundation;
4+
5+ class Request
6+ {
7+
8+ /**
9+ * Request body parameters ($_POST).
10+ *
11+ * @var InputBag<string|int|float|bool>
12+ */
13+ public $request;
14+
15+ /**
16+ * Query string parameters ($_GET).
17+ *
18+ * @var InputBag<string>
19+ */
20+ public $query;
21+
22+ /**
23+ * Cookies ($_COOKIE).
24+ *
25+ * @var InputBag<string>
26+ */
27+ public $cookies;
28+
29+ }
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ public function dataFileAsserts(): iterable
4444
4545 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/serializer.php ' );
4646 yield from $ this ->gatherAssertTypes (__DIR__ . '/data/denormalizer.php ' );
47+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/input_bag_from_request.php ' );
4748 }
4849
4950 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace InputBag ;
4+
5+ use Symfony \Component \HttpFoundation \Request ;
6+ use function PHPStan \Testing \assertType ;
7+
8+ class Foo
9+ {
10+
11+ public function doFoo (Request $ request ): void
12+ {
13+ assertType ('bool|float|int|string|null ' , $ request ->request ->get ('foo ' ));
14+ assertType ('string|null ' , $ request ->query ->get ('foo ' ));
15+ assertType ('string|null ' , $ request ->cookies ->get ('foo ' ));
16+
17+ assertType ('bool|float|int|string ' , $ request ->request ->get ('foo ' , 'foo ' ));
18+ assertType ('string ' , $ request ->query ->get ('foo ' , 'foo ' ));
19+ assertType ('string ' , $ request ->cookies ->get ('foo ' , 'foo ' ));
20+ }
21+
22+ }
You can’t perform that action at this time.
0 commit comments