Skip to content

Commit 85e52c5

Browse files
phpstan-botclaude
andcommitted
Add test for nested array reference tracking limitation
Nested arrays like `[[&$a]]` don't propagate reference updates through `$b[0][0] = 2` to `$a`. This documents the current behavior as a known limitation of the array reference tracking implementation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 59ca979 commit 85e52c5

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,23 @@ function testMultipleByRefInArray(): void
3232
assertType('2', $a);
3333
assertType("'bar'", $c);
3434
}
35+
36+
function testNested(): void
37+
{
38+
$a = 1;
39+
40+
$b = [[&$a]];
41+
assertType('1', $a);
42+
43+
$b[0][0] = 2;
44+
45+
assertType('1', $a); // Should be 2 in real PHP, but nested array reference tracking is not implemented
46+
47+
$b[0] = [];
48+
49+
assertType('1', $a);
50+
51+
$b[0][0] = 3;
52+
53+
assertType('1', $a);
54+
}

0 commit comments

Comments
 (0)