Skip to content

Commit af32820

Browse files
committed
Merge branch 2.1.x into 2.2.x
2 parents 95faa95 + 2f825fc commit af32820

4 files changed

Lines changed: 55 additions & 2 deletions

File tree

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3986,7 +3986,7 @@ private function tryProcessUnrolledConstantArrayForeach(
39863986
$iterScope,
39873987
$iterStorage,
39883988
new NoopNodeCallback(),
3989-
$context->enterDeep(),
3989+
$context,
39903990
)->filterOutLoopExitPoints();
39913991

39923992
$iterEndScope = $bodyResult->getScope();

tests/PHPStan/Analyser/nsrt/bug-14489.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function () {
2323
}
2424

2525
$values = array_values($cData);
26-
assertType('list{0?: array{1}|array{4}, 1?: array{1}|array{4}}', $values);
26+
assertType('array{array{1}, array{4}}', $values);
2727
};
2828

2929
function () {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug14543;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @return non-empty-list<int>
9+
*/
10+
function getItems(): array
11+
{
12+
return [1, 2, 3];
13+
}
14+
15+
$result = [];
16+
17+
foreach (['a', 'b'] as $key) {
18+
foreach (getItems() as $i) {
19+
$result[] = $i;
20+
}
21+
}
22+
23+
24+
assertType('non-empty-list<int>', $result);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug9332;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class HelloWorld
8+
{
9+
public function sayHello(): void
10+
{
11+
$data = ['a' => 'asdfghi'];
12+
foreach (['b', 'c'] as $x) {
13+
foreach (['d', 'e'] as $y) {
14+
$data[$x . $y] = mt_rand(1, 1000);
15+
}
16+
}
17+
18+
assertType("array{a: 'asdfghi', bd: int<1, 1000>, be: int<1, 1000>, cd: int<1, 1000>, ce: int<1, 1000>}", $data);
19+
$this->doSomething($data);
20+
}
21+
22+
/**
23+
* @param array{a: string, bd: int, be: int, cd: int, ce: int} $a
24+
*/
25+
private function doSomething(array $a): void
26+
{
27+
28+
}
29+
}

0 commit comments

Comments
 (0)