Commit 605f76c
Fix scope namespace not reset when entering global namespace block
- In NodeScopeResolver, when processing a `namespace { }` block (global namespace)
after a named namespace block, the scope's namespace was not being reset to null
- This caused PHPDoc resolution to use the wrong function name (prefixed with the
previous namespace), so PHPDoc annotations like `@return list<string>` were lost
- Added `else` branch in namespace handling to call `enterNamespace('')` for global
namespace blocks, which MutatingScope normalizes to `null`
- New regression test in tests/PHPStan/Rules/Functions/data/bug-13831.php
Closes phpstan/phpstan#138311 parent 2681e50 commit 605f76c
File tree
3 files changed
+21
-0
lines changed- src/Analyser
- tests/PHPStan/Rules/Functions
- data
3 files changed
+21
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
| 1013 | + | |
| 1014 | + | |
1013 | 1015 | | |
1014 | 1016 | | |
1015 | 1017 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
85 | 90 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments