File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ private static function findTestFiles(): iterable
211211 yield __DIR__ . '/../Rules/Arrays/data/bug-11679.php ' ;
212212 yield __DIR__ . '/../Rules/Methods/data/bug-4801.php ' ;
213213 yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php ' ;
214+ yield __DIR__ . '/../Rules/Methods/data/bug-12927.php ' ;
214215 }
215216
216217 /**
Original file line number Diff line number Diff line change 22
33namespace Bug12927 ;
44
5+ use function PHPStan \Testing \assertType ;
6+
57class HelloWorld
68{
79 /**
@@ -12,6 +14,22 @@ public function sayHello(array $list): array
1214 {
1315 foreach ($ list as $ k => $ v ) {
1416 unset($ list [$ k ]['abc ' ]);
17+ assertType ('non-empty-list<array{}|array{abc: string}> ' , $ list );
18+ assertType ('array{}|array{abc: string} ' , $ list [$ k ]);
19+ }
20+ return $ list ;
21+ }
22+
23+ /**
24+ * @param list<array<string, string>> $list
25+ * @return list<array<string>>
26+ */
27+ public function sayFoo (array $ list ): array
28+ {
29+ foreach ($ list as $ k => $ v ) {
30+ unset($ list [$ k ]['abc ' ]);
31+ assertType ('non-empty-list<array<string, string>> ' , $ list );
32+ assertType ('array<string, string> ' , $ list [$ k ]);
1533 }
1634 return $ list ;
1735 }
You can’t perform that action at this time.
0 commit comments