Skip to content

Incorrect property annotation on models with factories #1664

Closed
@scajal

Description

@scajal

Versions:

  • ide-helper Version: 3.5.4
  • Laravel Version: 11.39.0
  • PHP Version: 8.3

Description:

When generating Eloquent annotations on a model that uses a factory, the tool generates an incorrect $use_factory property with the following annotation:
@property-read \App\Models\TFactory|null $use_factory

Then, when running a static analysis tool (like Larastan), it fails:
PHPDoc tag @property-read for property App\Models\User::$use_factory contains unknown class App\Models\User\TFactory.

The model is defined as follows:

class User extends Model
{
    /** @use HasFactory<\Database\Factories\UserFactory>*/
    use HasFactory;

    ...
}

Steps To Reproduce:

  • Create a model with a factory
  • Apply the HasFactory trait to the model, and the corresponding @use
  • Generate the model's annotations
  • Run a static analysis tool (e.g.: Larastan)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions