Skip to content

Commit d1ebed8

Browse files
committed
added type assertions
1 parent ef319f3 commit d1ebed8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
/**

tests/PHPStan/Rules/Methods/data/bug-12927.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Bug12927;
44

5+
use function PHPStan\Testing\assertType;
6+
57
class 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
}

0 commit comments

Comments
 (0)