Commit 75cffd0
Fix phpstan/phpstan#11705: recompute ArrayDimFetch type in MutatingScope when key is narrowed
Revert the ArrayKeyExistsFunctionTypeSpecifyingExtension approach (shouldStoreArrayDimFetchType)
which caused regressions in bug-11276 and bug-13526 by not storing the value type needed by the
NonexistentOffset rule. Instead, fix in MutatingScope::resolveType(): when an ArrayDimFetch has
a stored expression type and its dim has been narrowed to a constant scalar, recompute the offset
value type and use it if strictly more specific than the stored type.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 2603236 commit 75cffd0
2 files changed
Lines changed: 18 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1047 | 1064 | | |
1048 | 1065 | | |
1049 | 1066 | | |
| |||
Lines changed: 0 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 57 | | |
74 | 58 | | |
75 | 59 | | |
| |||
125 | 109 | | |
126 | 110 | | |
127 | 111 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | 112 | | |
133 | 113 | | |
134 | 114 | | |
| |||
0 commit comments