Commit 1a121e8
Do not warn about ?? on non-$this typed properties without default value
Properties declared as `public int $i;` (without a default value) can be
uninitialized when accessed on external objects, so using ?? on them is valid.
Only warn when the property has a default value (guaranteed initialized).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent d282a5f commit 1a121e8
4 files changed
Lines changed: 15 additions & 9 deletions
File tree
- src/Rules
- tests/PHPStan/Rules/Variables
- data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
200 | 205 | | |
201 | 206 | | |
202 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | 213 | | |
218 | 214 | | |
219 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | 116 | | |
121 | 117 | | |
122 | 118 | | |
| |||
379 | 375 | | |
380 | 376 | | |
381 | 377 | | |
382 | | - | |
| 378 | + | |
383 | 379 | | |
384 | 380 | | |
385 | 381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments