Skip to content

Commit 55397e7

Browse files
committed
Update README.md
1 parent 8c7acca commit 55397e7

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,26 @@ PHPantom focuses on completion and go-to-definition and aims to do them really w
1414
| Completion ||||||
1515
| Auto-import || 💰 ||||
1616
| Go-to-definition ||||||
17-
| Go-to-implementation | || |||
18-
| `@mixin` completion || 💰 ||| |
19-
| `@phpstan-assert` narrowing ||| || ⚠️ partial |
20-
| Conditional return types ||||| |
21-
| Array shape inference ||||| |
22-
| Object shape completion ||||| |
23-
| `@phpstan-type` aliases ||| || |
17+
| Go-to-implementation | 🚧 || |||
18+
| `@mixin` completion || 💰 ||| 🚧 |
19+
| `@phpstan-assert` narrowing ||| 🚧 || 🚧 |
20+
| Conditional return types ||||| 🚧 |
21+
| Array shape inference ||||| 🚧 |
22+
| Object shape completion ||||| 🚧 |
23+
| `@phpstan-type` aliases ||| 🚧 || |
2424
| Hover ||||||
2525
| Signature help ||||||
2626
| Find references ||||||
27-
| Diagnostics |||| ⚠️ limited ||
27+
| Diagnostics |||| ||
2828
| Rename / refactoring || 💰 ||||
2929
| Time to ready | **10 ms** | 1 min 25 s | 3 min 17 s | 15 min 39 s | 19 min 38 s |
3030
| RAM usage | **7 MB** | 520 MB | 3.9 GB | 498 MB | 2.0 GB |
3131
| Disk cache | **0** | 45 MB | 0 | 4.1 GB | 551 MB |
3232

3333
<sub>Performance measured on a production codebase: 21K PHP files, 1.5M lines of code (vendor + application).</sub>
3434

35+
> **Want to verify?** Open [`example.php`](example.php) in your editor and trigger completion at the marked locations. It exercises every feature in the table, including edge cases where tools diverge.
36+
3537
## Context-Aware Intelligence
3638

3739
- **Smart PHPDoc completion.** `@throws` detects uncaught exceptions in the method body, including those propagated from called methods. `@param` pre-fills with the name and type from the signature. Tags are filtered to context: `@var` only in property docblocks, `@param` only when there are undocumented parameters. Already-documented tags aren't suggested again.

docs/todo.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,41 @@ native hint is the only concrete type information available. This also
195195
applies to method return types that use bare template parameters without
196196
a concrete substitution available.
197197

198+
### 23. Match-expression class-string not forwarded to conditional return types
199+
**Priority: Medium**
200+
201+
When a variable is assigned a `::class` value through a `match` expression
202+
and then passed to a function whose return type depends on that argument
203+
(e.g. `@template T @param class-string<T> @return T`), the resolver cannot
204+
trace the class-string back through the match arms:
205+
206+
```php
207+
$requestType = match ($typeName) {
208+
'creditnotes' => GetCreditnotesRequest::class,
209+
'orders' => GetOrdersRequest::class,
210+
};
211+
$requestBody = app()->make($requestType);
212+
$requestBody->enabled(); // ← no completion
213+
```
214+
215+
The resolver already handles direct `::class` arguments at the call site
216+
(e.g. `app()->make(GetCreditnotesRequest::class)`), but when the
217+
class-string is stored in an intermediate variable whose value comes from
218+
a match expression, the link is lost.
219+
220+
Two pieces are needed:
221+
222+
1. **Track class-string values from match arms.** When the RHS of an
223+
assignment is a `match` expression and every arm returns a `Foo::class`
224+
literal, record the set of possible class-string values on the
225+
variable (e.g. `$requestType` holds
226+
`GetCreditnotesRequest|GetOrdersRequest`).
227+
2. **Resolve class-string variables at call sites.** When a variable is
228+
passed as an argument to a function with a `@template` + conditional
229+
return type, look up the variable's class-string value(s) and use them
230+
for template substitution, producing a union of the possible return
231+
types.
232+
198233
---
199234

200235
## Go-to-Definition Gaps

0 commit comments

Comments
 (0)