Skip to content

Commit 2fb61a3

Browse files
phpstan-botclaude
andcommitted
Add test for optional offset in shouldUnionExistingItemType
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8778a00 commit 2fb61a3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ function () {
2020
}
2121
};
2222

23+
// Optional offset: the composed value has the optional key absent,
24+
// shouldUnionExistingItemType should handle this gracefully.
25+
function () {
26+
/** @var non-empty-list<array{test: false, extra?: string}> $list */
27+
$list = [];
28+
$list[0]['test'] = true;
29+
30+
foreach ($list as $item) {
31+
assertType('array{test: bool, extra?: string}', $item);
32+
}
33+
};
34+
2335
function () {
2436
$list = [];
2537

0 commit comments

Comments
 (0)