Skip to content

Commit 863e61d

Browse files
committed
Update docs
1 parent 2ba14f8 commit 863e61d

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ PHPantom focuses on completion and go-to-definition and aims to do them really w
2121
| Array shape inference ||||| 🚧 |
2222
| Object shape completion ||||| 🚧 |
2323
| `@phpstan-type` aliases ||| 🚧 |||
24+
| Generator body types | 🚧 || 🚧 |||
2425
| Hover ||||||
2526
| Signature help ||||||
2627
| Find references ||||||

docs/todo.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,65 @@ limitation.
5151

5252
---
5353

54+
#### 33a. Generator yield inference gaps inside generator bodies
55+
56+
The basic generator yield inference (item 33) is implemented, but
57+
several edge cases do not resolve yet:
58+
59+
**Yield inside control flow.** When `yield $var` appears inside an `if`,
60+
`foreach`, or other block within the generator body, the variable is not
61+
inferred outside that block. The text-based body scan finds the yield,
62+
but the variable resolution pipeline does not connect it back to the
63+
outer scope.
64+
65+
```php
66+
/** @return \Generator<int, User> */
67+
public function filteredUsers(): \Generator {
68+
if (true) {
69+
yield $user;
70+
}
71+
$user-> // ← no completion
72+
}
73+
```
74+
75+
**Multiple yields with different variable names.** When two separate
76+
variables are yielded in the same generator, neither resolves. The
77+
scan finds both yield statements but the inference does not fire for
78+
either variable.
79+
80+
```php
81+
/** @return \Generator<int, User> */
82+
public function allUsers(): \Generator {
83+
yield $first;
84+
$first-> // ← no completion
85+
86+
yield $second;
87+
$second-> // ← no completion
88+
}
89+
```
90+
91+
**Chaining through a yield-inferred variable.** When a variable gets
92+
its type from reverse yield inference, chaining a method call on it
93+
does not resolve the next link. The yield fallback returns the type
94+
directly from `resolve_variable_in_members` instead of feeding it
95+
back into the normal subject resolution chain.
96+
97+
```php
98+
/** @return \Generator<int, User> */
99+
public function withProfiles(): \Generator {
100+
yield $user;
101+
$user->getProfile()-> // ← no completion after getProfile()
102+
}
103+
```
104+
105+
**TSend inference not consistent across classes.** The `$var = yield`
106+
pattern resolves in some classes but not others with identical
107+
structure. Likely a position-dependent issue in
108+
`find_enclosing_return_type` where the backward scan crosses the
109+
wrong opening brace.
110+
111+
---
112+
54113
## Go-to-Implementation Gaps
55114

56115
### 5b. Short-name collisions in `find_implementors`

0 commit comments

Comments
 (0)