Commit c51adc8
Skip narrowing for non-constant arrays with multiple possible value types
For non-constant arrays like `non-empty-array<'a'|'b'>`, we cannot
guarantee any specific value is present, so no narrowing should occur
in the false context. Only narrow when the value type has exactly one
finite type (e.g. `non-empty-array<'a'>`).
Added regression test for this case.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 95757bf commit c51adc8
File tree
2 files changed
+16
-1
lines changed- src/Type/Php
- tests/PHPStan/Analyser/nsrt
2 files changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
0 commit comments