Commit d7da40a
Fix assignment inside match arm condition not recognized
- Variable assignments in match arm conditions (e.g. `is_dir($baseDir = ...)`)
were lost after commit 3beb8c6 replaced processExprNode with filterByTruthyValue
- filterByTruthyValue only narrows types without walking the AST, so assignments
within condition expressions were not discovered for the arm body scope
- Fix transfers newly-defined variables from the condition processing scope to
the body scope after applying truthiness filtering
- New regression test in tests/PHPStan/Rules/Variables/data/bug-13981.php
Closes phpstan/phpstan#139811 parent 03e0417 commit d7da40a
File tree
3 files changed
+47
-0
lines changed- src/Analyser
- tests/PHPStan/Rules/Variables
- data
3 files changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
211 | 212 | | |
212 | 213 | | |
213 | 214 | | |
| |||
4355 | 4356 | | |
4356 | 4357 | | |
4357 | 4358 | | |
| 4359 | + | |
4358 | 4360 | | |
4359 | 4361 | | |
4360 | 4362 | | |
| |||
4376 | 4378 | | |
4377 | 4379 | | |
4378 | 4380 | | |
| 4381 | + | |
| 4382 | + | |
| 4383 | + | |
| 4384 | + | |
| 4385 | + | |
| 4386 | + | |
| 4387 | + | |
| 4388 | + | |
| 4389 | + | |
| 4390 | + | |
| 4391 | + | |
| 4392 | + | |
| 4393 | + | |
| 4394 | + | |
| 4395 | + | |
| 4396 | + | |
| 4397 | + | |
| 4398 | + | |
| 4399 | + | |
| 4400 | + | |
| 4401 | + | |
| 4402 | + | |
| 4403 | + | |
| 4404 | + | |
4379 | 4405 | | |
4380 | 4406 | | |
4381 | 4407 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1257 | 1257 | | |
1258 | 1258 | | |
1259 | 1259 | | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1260 | 1271 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments