Commit 3f56074
Use isSuperTypeOf for all types in conditional expression matching
Instead of restricting isSuperTypeOf to integer ranges, use a two-pass
strategy: try exact matches first, then fall back to isSuperTypeOf
when no exact match exists. The fallback only accepts a single match
to avoid intersecting potentially conflicting results from overlapping
conditions (e.g. mixed~null, mixed~false, mixed~0 all being supertypes
of false).
This generalizes the fix beyond IntegerRangeType while keeping existing
behavior intact. Updated bug-5051 test expectations to reflect improved
precision (PHPStan can now narrow $update to false when $data is known).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 13f95d5 commit 3f56074
File tree
2 files changed
+36
-27
lines changed- src/Analyser
- tests/PHPStan/Analyser/nsrt
2 files changed
+36
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2154 | 2154 | | |
2155 | 2155 | | |
2156 | 2156 | | |
2157 | | - | |
2158 | | - | |
2159 | | - | |
2160 | | - | |
2161 | | - | |
2162 | | - | |
2163 | | - | |
2164 | | - | |
2165 | | - | |
2166 | | - | |
2167 | | - | |
2168 | | - | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
2174 | | - | |
| 2157 | + | |
2175 | 2158 | | |
2176 | 2159 | | |
2177 | 2160 | | |
| |||
3246 | 3229 | | |
3247 | 3230 | | |
3248 | 3231 | | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
3249 | 3254 | | |
3250 | 3255 | | |
3251 | 3256 | | |
3252 | 3257 | | |
3253 | 3258 | | |
3254 | 3259 | | |
3255 | 3260 | | |
3256 | | - | |
3257 | | - | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
3258 | 3267 | | |
3259 | 3268 | | |
3260 | 3269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
0 commit comments