Commit 418ecc5
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 925f29c commit 418ecc5
File tree
3 files changed
+52
-0
lines changed- src/Analyser
- tests/PHPStan/Rules/Variables
- data
3 files changed
+52
-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 | | |
| |||
4386 | 4387 | | |
4387 | 4388 | | |
4388 | 4389 | | |
| 4390 | + | |
4389 | 4391 | | |
4390 | 4392 | | |
4391 | 4393 | | |
| |||
4407 | 4409 | | |
4408 | 4410 | | |
4409 | 4411 | | |
| 4412 | + | |
| 4413 | + | |
| 4414 | + | |
| 4415 | + | |
| 4416 | + | |
| 4417 | + | |
| 4418 | + | |
| 4419 | + | |
| 4420 | + | |
| 4421 | + | |
| 4422 | + | |
| 4423 | + | |
| 4424 | + | |
| 4425 | + | |
| 4426 | + | |
| 4427 | + | |
| 4428 | + | |
| 4429 | + | |
| 4430 | + | |
| 4431 | + | |
| 4432 | + | |
| 4433 | + | |
| 4434 | + | |
| 4435 | + | |
4410 | 4436 | | |
4411 | 4437 | | |
4412 | 4438 | | |
| |||
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 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments