You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/todo/config.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,5 @@ Controls which external tools PHPantom proxies for diagnostics.
98
98
99
99
## Implementation order
100
100
101
-
1. ✅ **Config loading.** Read `.phpantom.toml` from the workspace root on `initialized`. Deserialize with `toml` + `serde`. Missing file means all defaults. *Done — `src/config.rs` module, loaded during `initialized` in `server.rs`. Parse errors are reported as a warning to the user.*
102
-
2.**Config writing.** When PHPantom prompts the user and gets an answer, write or update the relevant key. Preserve comments and formatting (use `toml_edit` crate).
103
-
3. ✅ **PHP version override.** Wire `[php].version` into the existing version detection path. *Done — config override takes precedence over `composer.json` detection.*
104
-
4.**Diagnostic proxying.** Wire `[diagnostics]` toggles into the proxy infrastructure as each provider is implemented. *Partially done — `unresolved-member-access` toggle is wired; external tool toggles (`phpstan`, `phpmd`, etc.) await proxy infrastructure.*
101
+
1.**Config writing.** When PHPantom prompts the user and gets an answer, write or update the relevant key. Preserve comments and formatting (use `toml_edit` crate).
102
+
2.**Diagnostic proxying.** Wire `[diagnostics]` toggles into the proxy infrastructure as each provider is implemented. *Partially done — `unresolved-member-access` toggle is wired; external tool toggles (`phpstan`, `phpmd`, etc.) await proxy infrastructure.*
Copy file name to clipboardExpand all lines: docs/todo/diagnostics.md
+4-60Lines changed: 4 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,76 +11,20 @@ within the same impact tier.
11
11
---
12
12
13
13
## 2. Resolution-failure diagnostics
14
-
**Impact: Medium · Effort: Medium***(mostly done — unresolved class/interface, unresolved member access, and unresolvable subject type implemented; unresolved function and unresolved PHPDoc type remain)*
15
-
16
-
Report diagnostics only for symbols and types that PHPantom's own engine
17
-
failed to resolve. This is **not** a general PHP linter — we don't check
18
-
argument counts, type compatibility, or missing semicolons. The goal is
19
-
twofold:
20
-
21
-
1.**Surface bugs in our engine.** On well-typed projects, every
22
-
diagnostic is a false positive that points at a resolution code path
23
-
we need to fix. This gives us a live regression signal.
24
-
2.**Guide under-typed projects.** On projects that aren't fully typed,
25
-
the diagnostics show exactly where adding annotations would unlock
26
-
completion and go-to-definition.
14
+
**Impact: Medium · Effort: Medium**
27
15
28
-
All diagnostics should be published on `textDocument/didOpen` and
29
-
`textDocument/didChange` (debounced). Severity is **Warning** for
30
-
unresolved types (the code may still run fine) and **Hint** or
31
-
**Information** for softer signals.
16
+
Unresolved class/interface, unresolved member access, and unresolvable
17
+
subject type diagnostics are already implemented. Two diagnostic types
18
+
remain:
32
19
33
20
### Diagnostics to emit
34
21
35
22
| Diagnostic | Trigger | Severity | Example |
36
23
|---|---|---|---|
37
-
| ✅ Unresolved class/interface | A type hint, `extends`, `implements`, `new`, or `::` reference that `find_or_load_class` cannot resolve after all phases (ast_map → classmap → PSR-4 → stubs) | Warning |`Class 'App\Foo' not found`|*Done — `diagnostics::unknown_classes` module*|
38
24
| Unresolved function | A function call that `find_or_load_function` cannot resolve (global functions, namespaced functions, stubs) | Warning |`Function 'do_thing' not found`|
39
-
| ✅ Unresolved member access |`->method()` or `->property` on a type we *did* resolve, but the member doesn't exist after full resolution (inheritance + virtual providers) | Warning |`Method 'frobnicate' not found on class 'App\Bar'`|*Done — `diagnostics::unknown_members` module. PHPactor benchmark fixtures `lots_of_missing_methods` and `method_chain` enabled in `benches/completion.rs`.*|
40
-
| ✅ Unresolvable subject type (opt-in) |`->method()`, `?->method()`, or `::method()` where PHPantom cannot resolve the subject type at all (e.g. `mixed`, untyped variable, uninferrable return type) | Hint |`Cannot resolve type of '$x'. Add a type annotation or PHPDoc tag to enable full IDE support.`|*Done — `diagnostics::unresolved_member_access` module. Off by default; enable via `[diagnostics] unresolved-member-access = true` in `.phpantom.toml`.*|
41
25
| Unresolved type in PHPDoc | A `@return`, `@param`, `@var`, `@throws`, `@mixin`, or `@extends` tag references a class that cannot be resolved | Information |`Type 'SomeAlias' in @return could not be resolved`|
42
26
43
27
44
-
### What we explicitly do NOT report
45
-
46
-
- Syntax errors (Mago already handles that; we use error-tolerant parsing)
47
-
- Argument count / type mismatches (that's PHPStan's job)
48
-
- Unused variables, imports, or dead code
49
-
- Missing return types or parameter types
50
-
- Code style violations
51
-
52
-
### Implementation plan
53
-
54
-
1.**Add `publishDiagnostics` capability** in `initialize` response and
55
-
store a handle to the client notification sender.
56
-
2.**Collect diagnostics during `update_ast`** — the symbol map walk
57
-
already visits every class reference, member access, and function
58
-
call. At each site, attempt resolution; on failure, record a
59
-
`DiagnosticEntry { range, message, severity }`.
60
-
3.**Debounce and publish** — after `update_ast` completes (on open or
61
-
change), send `textDocument/publishDiagnostics` with the collected
62
-
entries. Debounce changes to ~200 ms so fast typing doesn't spam.
63
-
4.**Clear on close** — send an empty diagnostics array when a file is
64
-
closed.
65
-
5.**User opt-out** — respect a config flag (e.g.
66
-
`phpantom.diagnostics.enabled: bool`, default `true`) so users who
67
-
rely solely on PHPStan / Psalm can turn ours off.
68
-
69
-
### Design notes
70
-
71
-
-**False positive budget:** treat every false positive as a bug. If a
72
-
diagnostic fires on valid, well-typed code, the fix goes in the
73
-
resolution engine, not in a suppression list. This keeps us honest.
74
-
-**No cross-file diagnostics** — only diagnose the file being
75
-
edited/opened. We don't scan the whole project.
76
-
-**Stubs are authoritative** — if a symbol exists in phpstorm-stubs,
77
-
it's resolved. We don't warn about `array_map` not being found
78
-
because a stub was missing.
79
-
-**Performance** — resolution is already happening for completion and
80
-
definition; diagnostics piggyback on the same code paths. The
81
-
incremental cost should be small since we're just collecting failures
0 commit comments