Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3986,7 +3986,7 @@ private function tryProcessUnrolledConstantArrayForeach(
$iterScope,
$iterStorage,
new NoopNodeCallback(),
$context->enterDeep(),
$context,
)->filterOutLoopExitPoints();

$iterEndScope = $bodyResult->getScope();
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/bug-14489.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function () {
}

$values = array_values($cData);
assertType('list{0?: array{1}|array{4}, 1?: array{1}|array{4}}', $values);
assertType('array{array{1}, array{4}}', $values);
};

function () {
Expand Down
24 changes: 24 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-14543.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types = 1);

namespace Bug14543;

use function PHPStan\Testing\assertType;

/**
* @return non-empty-list<int>
*/
function getItems(): array
{
return [1, 2, 3];
}

$result = [];

foreach (['a', 'b'] as $key) {
foreach (getItems() as $i) {
$result[] = $i;
}
}


assertType('non-empty-list<int>', $result);
29 changes: 29 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-9332.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types = 1);

namespace Bug9332;

use function PHPStan\Testing\assertType;

class HelloWorld
{
public function sayHello(): void
{
$data = ['a' => 'asdfghi'];
foreach (['b', 'c'] as $x) {
foreach (['d', 'e'] as $y) {
$data[$x . $y] = mt_rand(1, 1000);
}
}

assertType("array{a: 'asdfghi', bd: int<1, 1000>, be: int<1, 1000>, cd: int<1, 1000>, ce: int<1, 1000>}", $data);
$this->doSomething($data);
}

/**
* @param array{a: string, bd: int, be: int, cd: int, ce: int} $a
*/
private function doSomething(array $a): void
{

}
}
Loading