Skip to content

Commit 2233862

Browse files
committed
Merge MixinProvider into PHPDocProvider
1 parent a687c13 commit 2233862

7 files changed

Lines changed: 678 additions & 683 deletions

File tree

docs/ARCHITECTURE.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ src/
2525
├── inheritance.rs # Base class inheritance merging (traits, parent chain)
2626
├── virtual_members/
2727
│ ├── mod.rs # VirtualMemberProvider trait, VirtualMembers struct, merge logic
28-
│ ├── phpdoc.rs # PHPDocProvider (@method, @property, @property-read, @property-write)
29-
│ └── mixin.rs # MixinProvider (@mixin class member forwarding)
28+
│ └── phpdoc.rs # PHPDocProvider (@method, @property, @property-read, @property-write, @mixin)
3029
├── subject_extraction.rs # Shared helpers for extracting subjects before ->, ?->, ::
3130
├── util.rs # Position conversion, class lookup, logging
3231
├── parser/
@@ -227,11 +226,8 @@ ClassInfo (own members)
227226
├── 1. Merge used traits (via `use TraitName;`)
228227
│ └── Recursively follows trait composition and parent_class chains
229228
230-
├── 2. Walk the extends chain (parent_class)
231-
│ └── For each parent: merge its traits, then its public/protected members
232-
233-
└── 3. Merge @mixin classes (lowest precedence)
234-
└── Resolved with full inheritance, only public members
229+
└── 2. Walk the extends chain (parent_class)
230+
└── For each parent: merge its traits, then its public/protected members
235231
```
236232

237233
### Virtual Member Providers
@@ -259,22 +255,19 @@ resolve_class_fully(class)
259255
Provider priority order (highest first):
260256

261257
1. **Framework provider** (e.g. Laravel): richest type info
262-
2. **PHPDoc provider**: `@method`, `@property`, `@property-read`, `@property-write`
263-
3. **Mixin provider**: `@mixin` class members
258+
2. **PHPDoc provider**: `@method`, `@property`, `@property-read`, `@property-write`, `@mixin`
264259

265-
Three providers are currently registered in `default_providers()`:
260+
Two providers are currently registered in `default_providers()`:
266261

267262
- **`LaravelModelProvider`** (`virtual_members/laravel.rs`): synthesizes virtual members for classes extending `Illuminate\Database\Eloquent\Model`. Currently produces relationship properties: methods returning known relationship types (`HasMany`, `HasOne`, `BelongsTo`, etc.) generate a virtual property with the same name, typed from the relationship's generic parameters (e.g. `HasMany<Post, $this>` produces a `$posts` property typed as `\Illuminate\Database\Eloquent\Collection<Post>`). Highest priority among virtual member providers.
268-
- **`PHPDocProvider`** (`virtual_members/phpdoc.rs`): parses `@method`, `@property`, `@property-read`, and `@property-write` tags from the class-level docblock stored in `ClassInfo.class_docblock`. These tags are not parsed eagerly during AST extraction; instead, the raw docblock string is preserved and parsed lazily when `provide` is called.
269-
- **`MixinProvider`** (`virtual_members/mixin.rs`): loads classes listed in `@mixin` tags and returns their public members. Recurses into mixin-of-mixin chains up to `MAX_MIXIN_DEPTH`.
263+
- **`PHPDocProvider`** (`virtual_members/phpdoc.rs`): parses `@method`, `@property`, `@property-read`, `@property-write`, and `@mixin` tags from the class-level docblock stored in `ClassInfo.class_docblock`. Explicit `@method` / `@property` tags are not parsed eagerly during AST extraction; instead, the raw docblock string is preserved and parsed lazily when `provide` is called. For `@mixin` tags, the provider loads the referenced classes and merges their public members. Within the provider, explicit tags take precedence over mixin members. Recurses into mixin-of-mixin chains up to `MAX_MIXIN_DEPTH`.
270264

271265
### Precedence Rules
272266

273267
- **Class own members** always win.
274268
- **Trait members** override inherited members but not own members.
275269
- **Parent members** fill in anything not already present.
276-
- **Mixin members** have the lowest precedence within base resolution.
277-
- **Virtual members** from providers sit below all real declared members (own, trait, parent). Higher-priority providers shadow lower-priority ones.
270+
- **Virtual members** from providers sit below all real declared members (own, trait, parent). Higher-priority providers shadow lower-priority ones. Within the PHPDoc provider, `@method` / `@property` tags beat `@mixin` members.
278271
- **Private members** are never inherited from parents (but trait private members are copied, matching PHP semantics).
279272

280273
### Interface Inheritance in Traits/Used Interfaces

src/completion/resolver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@ impl Backend {
990990
// In docblocks `@return $this` means "the instance the method is
991991
// called on" — identical to `static` for inheritance, but when the
992992
// method comes from a `@mixin` the return type is rewritten to the
993-
// mixin class name during merge (see `MixinProvider` in
994-
// `virtual_members/mixin.rs`).
993+
// mixin class name during merge (see `PHPDocProvider` in
994+
// `virtual_members/phpdoc.rs`).
995995
if hint == "self" || hint == "static" || hint == "$this" {
996996
return all_classes
997997
.iter()

src/inheritance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// class own > traits > parent chain
99
///
1010
/// `@mixin` members are handled separately by
11-
/// [`MixinProvider`](crate::virtual_members::mixin::MixinProvider) in
11+
/// [`PHPDocProvider`](crate::virtual_members::phpdoc::PHPDocProvider) in
1212
/// the virtual member provider layer.
1313
///
1414
/// This module also supports **generic type substitution**: when a child

src/virtual_members/laravel.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
//! Synthesizes virtual members for classes that extend
44
//! `Illuminate\Database\Eloquent\Model`. This is the highest-priority
55
//! virtual member provider: its contributions beat `@method` /
6-
//! `@property` tags (PHPDocProvider) and `@mixin` members
7-
//! (MixinProvider).
6+
//! `@property` / `@mixin` members (PHPDocProvider).
87
//!
98
//! Currently implements:
109
//!

0 commit comments

Comments
 (0)