22/**
33 * Laravel Demo Classes for PHPantom LSP
44 *
5- * Open any demo() method and trigger completion inside it.
5+ * Open any method and trigger completion inside it.
66 * Requires a real Laravel installation via `composer install`.
77 */
88
1717use Illuminate \Support \Facades \Lang ;
1818use Illuminate \Support \Facades \View ;
1919
20- // ── Eloquent Virtual Properties ─────────────────────────────────────────────
21- // Alphabetical — every property a through w should appear in order.
22- // Trigger completion on `$bakery->` and scan the list.
23-
24- class EloquentPropertyDemo
20+ class Demo
2521{
26- public function demo (): void
22+ // ── Eloquent Virtual Properties ─────────────────────────────────────────
23+ // Alphabetical — every property a through w should appear in order.
24+ // Trigger completion on `$bakery->` and scan the list.
25+
26+ public function eloquentProperty (): void
2727 {
2828 $ bakery = new Bakery ();
2929
@@ -35,7 +35,7 @@ public function demo(): void
3535 $ bakery ->dough_temp ; // $casts 'float' → float
3636 $ bakery ->egg_count ; // $attributes default → int
3737 $ bakery ->flour ; // $fillable (no cast/attr) → mixed
38- $ bakery ->fresh (); // #[Scope] method → Builder
38+ $ bakery ->freshlyBaked (); // #[Scope] attribute method → Builder
3939 $ bakery ->gluten_free ; // $attributes default → bool
4040 $ bakery ->headBaker ; // relationship HasOne → Baker
4141 $ bakery ->head_baker_count ; // relationship count → int
@@ -63,14 +63,11 @@ public function demo(): void
6363 $ post ->author ; // relationship BelongsTo → BlogAuthor
6464 $ post ->author ()->associate ($ post ->author ); // associate() on BelongsTo
6565 }
66- }
6766
6867
69- // ── Eloquent Query Builder ──── ──────────────────────────────────────────────
68+ // ── Eloquent Query Builder ──────────────────────────────────────────────
7069
71- class EloquentQueryDemo
72- {
73- public function demo (): void
70+ public function eloquentQuery (): void
7471 {
7572 // Builder-as-static forwarding
7673 BlogAuthor::where ('active ' , true );
@@ -93,7 +90,7 @@ public function demo(): void
9390
9491 // Scopes on Builder instances (convention and #[Scope] attribute)
9592 BlogAuthor::where ('active ' , 1 )->active ()->ofGenre ('sci-fi ' )->get ();
96- Bakery::where ('open ' , true )->fresh ()->get ();
93+ Bakery::where ('open ' , true )->freshlyBaked ()->get ();
9794 $ query = BlogAuthor::where ('genre ' , 'fiction ' );
9895 $ query ->active ();
9996 $ query ->orderBy ('name ' )->get ();
@@ -106,20 +103,17 @@ public function demo(): void
106103 Bakery::whereKitchenId (42 ); // from $guarded
107104 Bakery::whereOvenCode ('X9 ' ); // from $hidden
108105 Bakery::whereFlour ('rye ' )->whereApricot (true )->get ();
109- Bakery::where ('open ' , true )->whereFlour ('spelt ' )->fresh ()->first ();
106+ Bakery::where ('open ' , true )->whereFlour ('spelt ' )->freshlyBaked ()->first ();
110107
111108 // Conditionable when()/unless() chain continuation
112109 BlogAuthor::where ('active ' , 1 )->when (true , fn ($ q ) => $ q )->get ();
113110 BlogAuthor::where ('active ' , 1 )->unless (false , fn ($ q ) => $ q )->first ();
114111 }
115- }
116112
117113
118- // ── Custom Eloquent Collections ──── ─────────────────────────────────────────
114+ // ── Custom Eloquent Collections ─────────────────────────────────────────
119115
120- class CustomCollectionDemo
121- {
122- public function demo (): void
116+ public function customCollection (): void
123117 {
124118 // Builder chain → custom collection via #[CollectedBy]
125119 $ reviews = Review::where ('published ' , true )->get ();
@@ -131,14 +125,11 @@ public function demo(): void
131125 $ review = new Review ();
132126 $ review ->replies ->topRated (); // HasMany<Review> → ReviewCollection
133127 }
134- }
135128
136129
137- // ── Eloquent Closure Parameter Inference ──── ────────────────────────────────
130+ // ── Eloquent Closure Parameter Inference ────────────────────────────────
138131
139- class EloquentClosureDemo
140- {
141- public function demo (): void
132+ public function eloquentClosure (): void
142133 {
143134 // Eloquent chunk — $orders inferred as Collection
144135 BlogAuthor::where ('active ' , true )->chunk (100 , function ($ orders ) {
@@ -162,13 +153,10 @@ public function demo(): void
162153 $ q ->where ('active ' , true ); // resolves to Builder<BlogAuthor>
163154 });
164155 }
165- }
166156
167157
168- // ── Laravel Config & Env Navigation ──── ─────────────────────────────────────
158+ // ── Laravel Config & Env Navigation ─────────────────────────────────────
169159
170- class LaravelConfigEnvDemo
171- {
172160 /**
173161 * "Go to Definition" and "Find All References" for config keys and env vars.
174162 *
@@ -177,7 +165,7 @@ class LaravelConfigEnvDemo
177165 * 2. Ctrl+Click "APP_KEY" to jump to .env.
178166 * 3. "Find All References" on "app.name" to see all usage sites.
179167 */
180- public function demo (): void
168+ public function laravelConfigEnv (): void
181169 {
182170 // Global helper
183171 config ('app.name ' );
@@ -190,13 +178,10 @@ public function demo(): void
190178 env ('APP_KEY ' );
191179 env ('DB_PASSWORD ' , 'secret ' );
192180 }
193- }
194181
195182
196- // ── Laravel View, Route & Translation Navigation ──── ───────────────────────
183+ // ── Laravel View, Route & Translation Navigation ───────────────────────
197184
198- class LaravelNavigationDemo
199- {
200185 /**
201186 * "Go to Definition" and "Find All References" for Laravel identifiers.
202187 *
@@ -206,7 +191,7 @@ class LaravelNavigationDemo
206191 * 3. Ctrl+Click "home" to jump to the ->name('home') declaration in routes/web.php.
207192 * 4. Ctrl+Click "auth.failed" to jump to lang/en/auth.php.
208193 */
209- public function demo (): void
194+ public function laravelNavigation (): void
210195 {
211196 // Blade Views
212197 view ('welcome ' );
@@ -224,14 +209,11 @@ public function demo(): void
224209 Lang::get ('pagination.next ' );
225210 Lang::has ('validation.required ' );
226211 }
227- }
228212
229213
230- // ── Laravel Config (definition & references) ──── ────────────────────────────
214+ // ── Laravel Config (definition & references) ────────────────────────────
231215
232- class LaravelConfigDemo
233- {
234- public function demo (): void
216+ public function laravelConfig (): void
235217 {
236218 config ('app.name ' );
237219 Config::get ('database.default ' );
0 commit comments