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
211
211
yield __DIR__ . '/../Rules/Arrays/data/bug-11679.php ' ;
212
212
yield __DIR__ . '/../Rules/Methods/data/bug-4801.php ' ;
213
213
yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php ' ;
214
+ yield __DIR__ . '/../Rules/Methods/data/bug-12927.php ' ;
214
215
}
215
216
216
217
/**
Original file line number Diff line number Diff line change 2
2
3
3
namespace Bug12927 ;
4
4
5
+ use function PHPStan \Testing \assertType ;
6
+
5
7
class HelloWorld
6
8
{
7
9
/**
@@ -12,6 +14,22 @@ public function sayHello(array $list): array
12
14
{
13
15
foreach ($ list as $ k => $ v ) {
14
16
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 ]);
15
33
}
16
34
return $ list ;
17
35
}
You can’t perform that action at this time.
0 commit comments