File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ private static function findTestFiles(): iterable
112112 yield __DIR__ . '/../Rules/Functions/data/varying-acceptor.php ' ;
113113 yield __DIR__ . '/../Rules/Methods/data/bug-4415.php ' ;
114114 yield __DIR__ . '/../Rules/Methods/data/bug-5372.php ' ;
115+ yield __DIR__ . '/../Rules/PhpDoc/data/bug-11033.php ' ;
115116 yield __DIR__ . '/../Rules/Arrays/data/bug-5372_2.php ' ;
116117 yield __DIR__ . '/../Rules/Methods/data/bug-5562.php ' ;
117118
Original file line number Diff line number Diff line change @@ -193,4 +193,9 @@ public function testGenericCallables(): void
193193 ]);
194194 }
195195
196+ public function testBug11033 (): void
197+ {
198+ $ this ->analyse ([__DIR__ . '/data/bug-11033.php ' ], []);
199+ }
200+
196201}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug11033 ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ /**
8+ * @phpstan-template T of GotoTarget
9+ *
10+ * @phpstan-type CandidateNotesData array{candidate: string, note: string}
11+ * @phpstan-type PersonalmanagerData array{token: string}
12+ *
13+ * @phpstan-type GotoRouteDataTypes array{
14+ * 'personalmanager': PersonalmanagerData,
15+ * 'my-pending-reviews': null,
16+ * 'candidate-notes': CandidateNotesData,
17+ * 'dashboard': null,
18+ * }
19+ */
20+ final class GotoRoute
21+ {
22+ /**
23+ * @phpstan-var T
24+ */
25+ public GotoTarget $ target ;
26+
27+ /**
28+ * @phpstan-var GotoRouteDataTypes[value-of<T>]
29+ */
30+ public ?array $ data = null ;
31+ }
32+
33+ enum GotoTarget: string
34+ {
35+ case PERSONALMANAGER = 'personalmanager ' ;
36+ case MY_PENDING_REVIEWS = 'my-pending-reviews ' ;
37+ case CANDIDATE_NOTES = 'candidate-notes ' ;
38+ case DASHBOARD = 'dashboard ' ;
39+ }
40+
41+ function (): void {
42+ /** @var GotoRoute<GotoTarget::PERSONALMANAGER> $goto */
43+ $ goto = new GotoRoute ();
44+ assertType ('array{token: string} ' , $ goto ->data );
45+ };
46+
47+ function (): void {
48+ /** @var GotoRoute<GotoTarget::DASHBOARD> $goto */
49+ $ goto = new GotoRoute ();
50+ assertType ('null ' , $ goto ->data );
51+ };
You can’t perform that action at this time.
0 commit comments