Commit 15b7ed0
committed
Fix phpstan/phpstan#14274: "Variable might not be defined" false positive
- Fixed invalidateExpression() dropping all ConditionalExpressionHolders for a
variable when only some holders had an invalidated condition guard
- Previously, `continue 3` skipped the entire variable's holders when any single
holder's condition guard matched the invalidated expression
- Now filters holders individually, preserving valid holders (e.g. those guarded
by $has_staged_update) when unrelated holders (e.g. those guarded by $messages)
are invalidated
- New regression test in tests/PHPStan/Rules/Variables/data/bug-14274.php1 parent b24bd5e commit 15b7ed0
3 files changed
Lines changed: 75 additions & 3 deletions
File tree
- src/Analyser
- tests/PHPStan/Rules/Variables
- data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2893 | 2893 | | |
2894 | 2894 | | |
2895 | 2895 | | |
2896 | | - | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
2897 | 2899 | | |
2898 | 2900 | | |
2899 | 2901 | | |
2900 | 2902 | | |
2901 | | - | |
| 2903 | + | |
| 2904 | + | |
2902 | 2905 | | |
2903 | 2906 | | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
2904 | 2915 | | |
2905 | | - | |
| 2916 | + | |
| 2917 | + | |
2906 | 2918 | | |
2907 | 2919 | | |
2908 | 2920 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1403 | 1403 | | |
1404 | 1404 | | |
1405 | 1405 | | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
1406 | 1417 | | |
1407 | 1418 | | |
1408 | 1419 | | |
| |||
| 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 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments