|
1 | 1 | # PHPantomLSP |
2 | 2 |
|
3 | | -A PHP Language Server Protocol (LSP) implementation in Rust. |
| 3 | +A fast, lightweight PHP language server that stays out of your way. Using only a few MB of RAM regardless of project size, fully usable in milliseconds, without requiring high-end hardware. |
4 | 4 |
|
5 | | -> **Note:** This project is in early development. Features are minimal. |
| 5 | +> **Note:** This project is in active development. |
6 | 6 |
|
7 | 7 | ## Features |
8 | 8 |
|
9 | 9 | ### Document Synchronization |
10 | 10 |
|
11 | 11 | - Full text document sync (open, change, close) |
12 | 12 |
|
| 13 | +### Type Resolution |
| 14 | + |
| 15 | +Both completion and go-to-definition draw from a shared type resolution engine: |
| 16 | + |
| 17 | +- `$this`, `self`, `static`, and `parent` keyword resolution |
| 18 | +- Variable type inference from assignments (`$var = new Foo()`) and parameter type hints |
| 19 | +- Property chain and method call chaining (e.g. `$this->getService()->doSomething()`) |
| 20 | +- Function and static method call return type resolution (e.g. `app()->`, `Class::make()->`) |
| 21 | +- Inheritance-aware: walks the class hierarchy including traits |
| 22 | +- Enum case resolution |
| 23 | +- Union types: `A|B` in return types, property types, and parameter hints are split into individual candidates |
| 24 | +- Ambiguous variables: when a variable is assigned different types in conditional branches, all possible types are tried |
| 25 | +- PHPDoc support: `@return`, `@property`, `@method`, `@mixin` |
| 26 | +- PHPStan conditional return types: annotations like `@return ($abstract is class-string<TClass> ? TClass : mixed)` are resolved based on call-site arguments |
| 27 | + |
13 | 28 | ### Completion |
14 | 29 |
|
15 | 30 | - Instance member completion via `->` (methods and properties) |
16 | | -- Static member completion via `::` (static methods, static properties, and constants) |
| 31 | +- Static member completion via `::` (static methods, static properties, constants, and enum cases) |
17 | 32 | - `parent::` completion (static and non-static members, excluding private) |
18 | | -- `$this`, `self`, and `static` keyword resolution to the current class |
19 | | -- Property chain resolution (e.g. `$this->service->`) |
20 | | -- Variable type resolution from assignments (`$var = new Foo()`) and parameter type hints |
21 | | -- Inheritance-aware completion — walks the class hierarchy to include inherited members |
22 | 33 | - Magic method filtering (`__construct`, `__destruct`, etc. are excluded from results) |
23 | 34 | - Full method signature display in completion labels (parameters, types, return type) |
24 | 35 |
|
25 | 36 | <img width="683" height="339" alt="image" src="https://github.com/user-attachments/assets/65e8220d-5d94-466f-aea7-2f239a8d4b19" /> |
26 | 37 |
|
27 | 38 | ### Go to Definition |
28 | 39 |
|
29 | | -- Jump to class, interface, trait, and enum definitions |
| 40 | +- Jump to class, interface, trait, enum, and standalone function definitions |
| 41 | +- Jump to method, property, and constant definitions on a class |
30 | 42 | - Same-file and cross-file definition lookup |
31 | 43 | - Fully-qualified, partially-qualified, and unqualified name resolution via `use` statements and the current namespace |
32 | 44 |
|
33 | 45 | ### PHP Parsing |
34 | 46 |
|
35 | | -- Extracts classes, interfaces, methods, properties, and constants |
36 | | -- Parses visibility modifiers, static modifiers, type hints, and parameter info |
| 47 | +- Extracts classes, interfaces, traits, and enums |
| 48 | +- Parses methods, properties, and constants with visibility, static modifiers, and type hints |
| 49 | +- Extracts standalone function definitions (global and namespaced) |
37 | 50 | - Supports constructor-promoted properties |
38 | 51 | - Parses `use` statements and namespace declarations |
39 | 52 |
|
| 53 | +#### PHPDoc Parsing |
| 54 | + |
| 55 | +Built on [Mago](https://github.com/carthage-software/mago)'s PHP parser. |
| 56 | + |
| 57 | +- `@return` type extraction with compatibility checks against native type hints |
| 58 | +- `@var` type annotations |
| 59 | +- `@property` virtual property declarations |
| 60 | +- `@method` virtual method declarations |
| 61 | +- `@mixin` class delegation tags |
| 62 | +- PHPStan style conditional return type expressions (recursive/nested conditionals) |
| 63 | + |
40 | 64 | ### Composer / PSR-4 Integration |
41 | 65 |
|
42 | 66 | - Parses `composer.json` for PSR-4 autoload mappings (`autoload` and `autoload-dev`) |
@@ -93,4 +117,4 @@ See [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md). |
93 | 117 |
|
94 | 118 | ## License |
95 | 119 |
|
96 | | -MIT — see [LICENSE](LICENSE). |
| 120 | +MIT - see [LICENSE](LICENSE). |
0 commit comments