Commit d1de9eb
Fix false positive "Empty array passed to foreach" in closure with object use
- Don't carry forward property fetch expression types for dynamic (undeclared) properties on objects captured by value in closures
- Objects are references in PHP, so their properties can change between closure definition and invocation
- Only affects dynamic properties (e.g. stdClass); declared/native properties still carry forward type narrowings
- New regression test in tests/PHPStan/Rules/Arrays/data/bug-10345.php
Closes phpstan/phpstan#103451 parent 3222c52 commit d1de9eb
File tree
3 files changed
+46
-0
lines changed- src/Analyser
- tests/PHPStan/Rules/Arrays
- data
3 files changed
+46
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2152 | 2152 | | |
2153 | 2153 | | |
2154 | 2154 | | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
2155 | 2159 | | |
2156 | 2160 | | |
2157 | 2161 | | |
| |||
2218 | 2222 | | |
2219 | 2223 | | |
2220 | 2224 | | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
2221 | 2247 | | |
2222 | 2248 | | |
2223 | 2249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
| 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 | + | |
0 commit comments