File tree Expand file tree Collapse file tree 3 files changed +34
-17
lines changed Expand file tree Collapse file tree 3 files changed +34
-17
lines changed Original file line number Diff line number Diff line change 3
3
namespace PHPStan \Type \Symfony ;
4
4
5
5
use PHPStan \Testing \TypeInferenceTestCase ;
6
+ use ReflectionClass ;
6
7
use ReflectionMethod ;
7
8
use Symfony \Component \HttpFoundation \Request ;
8
9
use function class_exists ;
@@ -46,6 +47,11 @@ public function dataFileAsserts(): iterable
46
47
47
48
if (class_exists ('Symfony\Bundle\FrameworkBundle\Controller\AbstractController ' )) {
48
49
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/ExampleAbstractController.php ' );
50
+
51
+ $ ref = new ReflectionClass ('Symfony\Bundle\FrameworkBundle\Controller\AbstractController ' );
52
+ if ($ ref ->hasMethod ('get ' )) {
53
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/ExampleAbstractControllerServices.php ' );
54
+ }
49
55
}
50
56
51
57
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/serializer.php ' );
Original file line number Diff line number Diff line change 10
10
final class ExampleAbstractController extends AbstractController
11
11
{
12
12
13
- public function services (): void
14
- {
15
- assertType ('Foo ' , $ this ->get ('foo ' ));
16
- assertType ('Foo ' , $ this ->get ('parameterised_foo ' ));
17
- assertType ('Foo\Bar ' , $ this ->get ('parameterised_bar ' ));
18
- assertType ('Synthetic ' , $ this ->get ('synthetic ' ));
19
- assertType ('object ' , $ this ->get ('bar ' ));
20
- assertType ('object ' , $ this ->get (doFoo ()));
21
- assertType ('object ' , $ this ->get ());
22
-
23
- assertType ('true ' , $ this ->has ('foo ' ));
24
- assertType ('true ' , $ this ->has ('synthetic ' ));
25
- assertType ('false ' , $ this ->has ('bar ' ));
26
- assertType ('bool ' , $ this ->has (doFoo ()));
27
- assertType ('bool ' , $ this ->has ());
28
- }
29
-
30
13
public function parameters (ContainerInterface $ container , ParameterBagInterface $ parameterBag ): void
31
14
{
32
15
assertType ('array|bool|float|int|string|null ' , $ container ->getParameter ('unknown ' ));
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace PHPStan \Type \Symfony ;
4
+
5
+ use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
6
+ use function PHPStan \Testing \assertType ;
7
+
8
+ final class ExampleAbstractControllerServices extends AbstractController
9
+ {
10
+
11
+ public function services (): void
12
+ {
13
+ assertType ('Foo ' , $ this ->get ('foo ' ));
14
+ assertType ('Foo ' , $ this ->get ('parameterised_foo ' ));
15
+ assertType ('Foo\Bar ' , $ this ->get ('parameterised_bar ' ));
16
+ assertType ('Synthetic ' , $ this ->get ('synthetic ' ));
17
+ assertType ('object ' , $ this ->get ('bar ' ));
18
+ assertType ('object ' , $ this ->get (doFoo ()));
19
+ assertType ('object ' , $ this ->get ());
20
+
21
+ assertType ('true ' , $ this ->has ('foo ' ));
22
+ assertType ('true ' , $ this ->has ('synthetic ' ));
23
+ assertType ('false ' , $ this ->has ('bar ' ));
24
+ assertType ('bool ' , $ this ->has (doFoo ()));
25
+ assertType ('bool ' , $ this ->has ());
26
+ }
27
+
28
+ }
You can’t perform that action at this time.
0 commit comments