Commit 7f296d9
Fix count-based type narrowing for constant array unions
- Fixed specifyTypesForCountFuncCall to use direct type assignment instead
of TypeCombinator::remove for falsey context with fixed-size constant arrays
- The root cause was ConstantArrayType::isSuperTypeOf using structural
subtyping (array{mixed} is supertype of array{mixed, string|null, mixed}),
which made TypeCombinator::remove overly aggressive
- New regression test in tests/PHPStan/Analyser/nsrt/bug-11488.php
Closes phpstan/phpstan#114881 parent 099a0ba commit 7f296d9
File tree
2 files changed
+67
-0
lines changed- src/Analyser
- tests/PHPStan/Analyser/nsrt
2 files changed
+67
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1272 | 1272 | | |
1273 | 1273 | | |
1274 | 1274 | | |
| 1275 | + | |
| 1276 | + | |
1275 | 1277 | | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1276 | 1281 | | |
1277 | 1282 | | |
| 1283 | + | |
1278 | 1284 | | |
1279 | 1285 | | |
1280 | 1286 | | |
1281 | 1287 | | |
| 1288 | + | |
1282 | 1289 | | |
1283 | 1290 | | |
1284 | 1291 | | |
| |||
1371 | 1378 | | |
1372 | 1379 | | |
1373 | 1380 | | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
1374 | 1388 | | |
1375 | 1389 | | |
1376 | 1390 | | |
| |||
| 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 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments