Skip to content

Commit 44b2031

Browse files
committed
more tests
1 parent 81db5f5 commit 44b2031

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎tests/PHPStan/Analyser/NodeScopeResolverTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ private static function findTestFiles(): iterable
253253
yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php';
254254
yield __DIR__ . '/../Rules/Methods/data/bug-12927.php';
255255
yield __DIR__ . '/../Rules/Properties/data/bug-14012.php';
256+
yield __DIR__ . '/../Rules/Variables/data/bug-14124.php';
257+
yield __DIR__ . '/../Rules/Variables/data/bug-14124b.php';
256258
}
257259

258260
/**

‎tests/PHPStan/Rules/Variables/ParameterOutAssignedTypeRuleTest.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@ public function testBug14124(): void
8686
$this->analyse([__DIR__ . '/data/bug-14124.php'], []);
8787
}
8888

89+
public function testBug14124b(): void
90+
{
91+
$this->analyse([__DIR__ . '/data/bug-14124b.php'], []);
92+
}
93+
8994
}

‎tests/PHPStan/Rules/Variables/data/bug-14124.php‎

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

33
namespace Bug14124;
44

5+
use function PHPStan\Testing\assertType;
6+
57
/**
68
* @param array<string, list<string>> $convert
79
* @param-out array<string, list<string>> $convert
@@ -13,6 +15,7 @@ function example3a(array &$convert): void
1315
$val = strtoupper($val);
1416
}
1517
}
18+
assertType('array<string, list<string>>', $convert);
1619
}
1720

1821
/**
@@ -26,4 +29,5 @@ function example3b(array &$convert): void
2629
$convert[$outerKey][$key] = strtoupper($val);
2730
}
2831
}
32+
assertType('array<string, list<string>>', $convert);
2933
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Bug14124b;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @param array<string, list<list<string>>> $convert
9+
* @param-out array<string, list<list<string>>> $convert
10+
*/
11+
function example3a(array &$convert): void
12+
{
13+
foreach ($convert as &$inner) {
14+
foreach ($inner as &$val) {
15+
foreach ($val as &$val2) {
16+
$val2 = strtoupper($val2);
17+
}
18+
}
19+
}
20+
assertType('array<string, list<list<string>>>', $convert);
21+
}
22+
23+
/**
24+
* @param array<string, list<list<string>>> $convert
25+
* @param-out array<string, list<list<string>>> $convert
26+
*/
27+
function example3b(array &$convert): void
28+
{
29+
foreach ($convert as $outerKey => $inner) {
30+
foreach ($inner as $key => $val) {
31+
foreach ($val as $key2 => $val2) {
32+
$convert[$outerKey][$key][$key2] = strtoupper($val);
33+
}
34+
}
35+
}
36+
assertType('array<string, list<list<string>>>', $convert);
37+
}

0 commit comments

Comments
 (0)