Commit 2949e3d
Fix false positive "offset might not exist" for string offset in union
- Skip "might not exist" report for string types with integer offsets in
NonexistentOffsetInArrayDimFetchCheck decomposition check
- When a union of constant strings (e.g. ''|':') is accessed with a valid
integer offset, the decomposition incorrectly flagged it because one
member (empty string) returned "no" for the offset
- The union-level check already correctly returns "maybe" for such cases
- New regression test in tests/PHPStan/Rules/Arrays/data/bug-13688.php
Closes phpstan/phpstan#136881 parent c36922b commit 2949e3d
File tree
3 files changed
+20
-0
lines changed- src/Rules/Arrays
- tests/PHPStan/Rules/Arrays
- data
3 files changed
+20
-0
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1277 | 1277 | | |
1278 | 1278 | | |
1279 | 1279 | | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
1280 | 1285 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments