Commit 14cb6d0
Add regression test for
- Add regression test for phpstan/phpstan#6688 verifying that `@var` PHPDoc
annotations before `foreach` correctly define the expression variable in scope
- Test covers the original issue: `/** @var string[][] $result */ foreach ($result as $data)`
and the maintainer's reproduction: `/** @var string[] $c */ foreach ($c as $v)`
- The fix was applied in commit 4a08845 by moving the `processVarAnnotation`
call before `processExprNode` in the `Foreach_` branch of `NodeScopeResolver`
- Investigated analogous constructs (if, while, do-while, for, switch, match):
all are correctly handled by the general `processStmtVarAnnotation` call at
the top of `processStmtNode` — only `Foreach_` was excluded from that general
handling and needed its own pre-expression annotation processing@var annotation before foreach not defining the expression variable1 parent 03834ec commit 14cb6d0
2 files changed
Lines changed: 31 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1517 | 1517 | | |
1518 | 1518 | | |
1519 | 1519 | | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1520 | 1534 | | |
| 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 | + | |
0 commit comments