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
-**`parent::`** — inherited and overridden members (excludes private)
14
+
-**Traits and interfaces** — trait members appear on the using class; interface contracts are resolved
15
+
-**`@mixin` classes** — members from `@mixin` annotations are included, even when the mixin is declared on a parent class (the Laravel `Model`/`Builder` pattern works out of the box)
16
+
-**Magic members** — `@property`, `@property-read`, `@method` from PHPDoc
17
+
-**Method chaining** — return types are followed through arbitrarily long chains
18
+
-**Null-safe chaining** — `?->` is handled identically to `->`
19
+
-**Full signatures** in completion labels (parameters, types, return type)
20
+
- Magic methods (`__construct`, `__destruct`, etc.) are filtered out of results
PHPantom uses a shared analysis engine built on [Mago](https://github.com/carthage-software/mago)'s PHP parser for parsing and type resolution, powering both completion and go-to-definition.
24
+
### Go to Definition
16
25
17
-
- Extracts classes, interfaces, traits, enums, and standalone functions
18
-
- Parses methods, properties, constants, and constructor-promoted properties with visibility, static modifiers, and type hints
19
-
- Parses `use` statements and namespace declarations
- Resolves `$this`, `self`, `static`, and `parent` keywords
24
-
- Infers variable types from assignments and parameter type hints
25
-
- Supports property chains and method call chaining (e.g., `$this->getService()->doSomething()`)
26
-
- Resolves function and static method return types (e.g., `app()->`, `Class::make()->`)
27
-
- Inheritance-aware resolution including traits cases
28
-
- Handles union types (`A|B`) and ambiguous variables across conditional branches
26
+
-**Classes, interfaces, traits, enums** — same-file and cross-file
27
+
-**Methods, properties, constants** — resolves through inheritance, traits, and mixins
28
+
-**Standalone functions** — including PHP built-ins via embedded stubs
29
+
-**Variables** — jumps to the most recent assignment or declaration (assignment, parameter, `foreach`, `catch`, `static`/`global`)
30
+
-**Namespace resolution** — fully-qualified, partially-qualified, and aliased names via `use ... as ...`
29
31
30
-
### Completion
32
+
### Type Resolution
31
33
32
-
- Instance member completion via `->` (methods and properties)
33
-
- Static member completion via `::` (static methods, static properties, constants, and enum cases)
34
-
-`parent::` completion (static and non-static members, excluding private)
35
-
- Magic method filtering (`__construct`, `__destruct`, etc. are excluded from results)
36
-
- Full method signature display in completion labels (parameters, types, return type)
34
+
PHPantom infers variable types from assignments, parameter hints, return types, and PHPDoc annotations, then uses them to power both completion and go-to-definition.
-**Ambiguous variables** — when a variable is assigned different types in conditional branches, all candidates are offered
39
40
40
-
### Go to Definition
41
+
### Type Narrowing
42
+
43
+
Completion results adapt to runtime type checks. PHPantomLSP narrows union types in both the positive and inverse branches of `if`/`else`, `while`, and `match(true)`:
41
44
42
-
- Jump to class, interface, trait, enum, and standalone function definitions
43
-
- Jump to method, property, and constant definitions on a class
44
-
- Same-file and cross-file definition lookup
45
-
- Fully-qualified, partially-qualified, and unqualified name resolution via `use` statements and the current namespace
45
+
-`instanceof` and negated `!instanceof`
46
+
-`is_a($var, ClassName::class)`
47
+
-`get_class($var) === ClassName::class` and `$var::class === ClassName::class` (including `!==` and reversed operand order)
48
+
-`assert($var instanceof ClassName)`
49
+
-**Custom assertion functions** via `@phpstan-assert` / `@psalm-assert` annotations:
50
+
-`@phpstan-assert Type $param` — unconditional narrowing after the call
51
+
-`@phpstan-assert-if-true Type $param` — narrows in the then-branch
52
+
-`@phpstan-assert-if-false Type $param` — narrows in the else-branch
46
53
47
-
### Composer Integration
54
+
### Composer & Project Awareness
48
55
49
-
- Parses `composer.json` for PSR-4 class mapping
50
-
- Parses vendor autoload file and PSR-4 loading
51
-
- Caches parsed files in memory to avoid redundant loading
56
+
- Parses `composer.json` for PSR-4 and file autoload mappings
57
+
- Resolves cross-file class lookups on demand
52
58
53
59
## Building
54
60
55
-
PHPantomLSP embeds [JetBrains phpstorm-stubs](https://github.com/JetBrains/phpstorm-stubs) at compile time to provide type information for PHP's built-in classes and functions. The stubs are managed as a Composer dependency with`stubs/` as the vendor directory.
61
+
The PHPstubs are managed as a Composer dependency in`stubs/`. Install them before building:
0 commit comments