Commit f125b73
Fix multi-dimensional array shape wrongly inferred with hasOffsetValue
- When assigning to a nested array with a non-constant outer key like
$matrix[$size - 1][8] = 3, the HasOffsetValueType(8, 3) from the inner
dimension was incorrectly propagated to ALL entries of the outer array
- Added logic in AssignHandler::produceArrayDimFetchAssignValueToWrite()
to strip HasOffsetValueType from the inner value when the outer offset
is non-constant and the inner dimension was not a tracked expression
(i.e., not from a foreach binding)
- New regression test in tests/PHPStan/Analyser/nsrt/bug-10089.php
Fixes phpstan/phpstan#100891 parent 3c63f68 commit f125b73
2 files changed
Lines changed: 57 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
969 | 970 | | |
970 | 971 | | |
971 | 972 | | |
| 973 | + | |
972 | 974 | | |
973 | 975 | | |
974 | 976 | | |
| |||
1009 | 1011 | | |
1010 | 1012 | | |
1011 | 1013 | | |
| 1014 | + | |
1012 | 1015 | | |
1013 | | - | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
1014 | 1039 | | |
1015 | 1040 | | |
1016 | 1041 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments