Expand description
PHPantom — a fast, lightweight PHP language server.
Diagnostics are debounced: each did_change bumps a per-file version
counter and spawns a delayed task. The task only publishes if its
version still matches (i.e. no newer edit arrived in the meantime).
This crate is organised into the following modules:
types— Data structures for extracted PHP information (classes, methods, functions, etc.)parser— PHP parsing and AST extraction using mago_syntaxcompletion— Completion logic (target extraction, type resolution, item building, and the top-level completion request handler)composer— Composer autoload (PSR-4, classmap) parsing and class-to-file resolutionserver— The LSPLanguageServertrait implementation (thin wrapper that delegates to feature-specific modules)util— Utility helpers (position conversion, class lookup, logging)hover— Hover support (textDocument/hover). Resolves the symbol under the cursor and returns type information, method signatures, and docblock descriptionssignature_help— Signature help (textDocument/signatureHelp). Shows parameter hints while typing function/method arguments, with active-parameter trackingdefinition— Go-to-definition support for classes, members, and functionsinheritance— Base class inheritance resolution. Merges members from parent classes and traits into a unifiedClassInfovirtual_members— Virtual member provider abstraction. Defines theVirtualMemberProvidertrait and merge logic for members synthesized from@method/@propertytags,@mixinclasses, and framework-specific patterns (e.g. Laravel)resolution— Class and function lookup / name resolution (multi-phase: class_index → ast_map → classmap → PSR-4 → stubs)subject_extraction— Shared helpers for extracting the left-hand side of->,?->, and::access operators (used by both completion and definition)highlight— Document highlighting (textDocument/documentHighlight). When the cursor lands on a symbol, returns all other occurrences in the current file so the editor can highlight them. Uses the precomputedSymbolMapwith no additional parsing. Variables are scoped to their enclosing function/closure; class names, members, functions, and constants are file-global.semantic_tokens— Semantic tokens (textDocument/semanticTokens/full). Type-aware syntax highlighting that goes beyond TextMate grammars. MapsSymbolMapspans to LSP semantic token types (class, interface, enum, method, property, parameter, variable, function, constant) with modifiers (declaration, static, readonly, deprecated, abstract). ResolvesClassReferencespans to distinguish classes from interfaces, enums, and traits. Template parameter names from@templatetags are emitted astypeParametertokens.code_actions— Code actions (textDocument/codeAction). Provides:code_actions::import_class— Import class quick-fix (add ausestatement for unresolved class names)code_actions::remove_unused_import— Remove unused import quick-fix (delete individual or all unusedusestatements)code_actions::generate_constructor— Generate a constructor from non-static propertiescode_actions::generate_getter_setter— GenerategetX()/setX()accessor methods (orisX()forboolproperties) from a property declaration
diagnostics— Diagnostic collection and delivery. Supports both pull diagnostics (textDocument/diagnostic, LSP 3.17) and push diagnostics (textDocument/publishDiagnostics) as a fallback. Currently implemented providers:diagnostics::deprecated—@deprecatedusage diagnostics (strikethrough viaDiagnosticTag::Deprecatedon references to deprecated symbols)diagnostics::unused_imports— unusedusedimming (DiagnosticTag::Unnecessaryon imports with no references in the file)diagnostics::unknown_classes— unknown class diagnostics (Severity::WarningonClassReferencespans that cannot be resolved through any resolution phase)diagnostics::unresolved_member_access— opt-in diagnostic (Severity::HintonMemberAccessspans where the subject type cannot be resolved at all; enabled via[diagnostics] unresolved-member-access = truein.phpantom.toml)
docblock— PHPDoc block parsing, split into submodules:docblock::tags— tag extraction (@return,@var,@property,@method,@mixin,@deprecated,@phpstan-assert, docblock text retrieval)docblock::conditional— PHPStan conditional return type parsingdocblock::types— type utilities (split_type_token), PHPStan array shape parsing (parse_array_shape,extract_array_shape_value_type), and object shape parsing (parse_object_shape,extract_object_shape_property_type,is_object_shape)
Re-exports§
pub use types::AccessKind;pub use types::ClassInfo;pub use types::DefineInfo;pub use types::FunctionInfo;pub use types::Visibility;
Modules§
- analyse
- CLI analysis mode.
- classmap_
scanner - Fast byte-level PHP symbol scanners for early-stage file discovery.
- completion
- composer
- Composer autoload support.
- config
- Configuration loaded from
.phpantom.toml. - diagnostics
- Diagnostics — collect and deliver LSP diagnostics for PHP files.
- docblock
- PHPDoc block parsing.
- fix
- CLI fix mode.
- php_
type - Structured representation of PHP type expressions.
- stubs
- subject_
expr - Structured subject expression parsing.
- types
- Data types used throughout the PHPantom server.
Structs§
- Backend
- The main LSP backend that holds all server state.
Functions§
- extract_
completion_ target - Detect the access operator before the cursor position and extract
both the
AccessKindand the textual subject to its left. - resolve_
class_ fully - Resolve a class with full inheritance and virtual member providers.