π 1 minute read
When you generate a new factory in recent Laravel versions, you’ll notice a docblock like this above the class:
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
Itβs tempting to ignore it as boilerplate, but it serves a critical purpose for your Developer Experience (DX). This @extends tag tells your IDE (PHPStorm, VS Code) exactly which model this factory is responsible for.
By defining this relationship, your IDE can:
- Provide auto-complete for model attributes inside the
definition()method. - Correctly type-hint the return values when calling
factory()on the model. - Identify missing or misspelled attributes before you even run your tests.
Pro Tip: If you’re working on an older Laravel project that doesn’t have these docblocks, add them manually! It’s a quick way to reduce “red squiggles” and speed up your test writing.
Leave a Reply