Commit abdc52e
committed
Fix incorrect type narrowing of superglobal with dependent types
- Extended conditional expression skip logic in MutatingScope to handle
superglobal variables not present in the other branch's expression types
- Added exprContainsSuperGlobal() helper method to detect superglobal
expressions for reuse across merge logic
- New regression test in tests/PHPStan/Rules/Variables/data/bug-14421.php
- Root cause: superglobals always exist but aren't tracked in expressionTypes
unless narrowed, so the dependent type skip check failed to recognize them1 parent 2083a81 commit abdc52e
File tree
3 files changed
+47
-2
lines changed- src/Analyser
- tests/PHPStan/Rules/Variables
- data
3 files changed
+47
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
840 | 840 | | |
841 | 841 | | |
842 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
843 | 857 | | |
844 | 858 | | |
845 | 859 | | |
| |||
3603 | 3617 | | |
3604 | 3618 | | |
3605 | 3619 | | |
| 3620 | + | |
| 3621 | + | |
| 3622 | + | |
| 3623 | + | |
| 3624 | + | |
3606 | 3625 | | |
3607 | | - | |
3608 | | - | |
| 3626 | + | |
3609 | 3627 | | |
3610 | 3628 | | |
3611 | 3629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
565 | 572 | | |
| 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 | + | |
0 commit comments