Skip to content

Conflict with larastan: or I get the phpstan error, or I get a code quality score on Insights #687

@giacomomasseron

Description

@giacomomasseron
Q A
Bug report? no
Feature request? yes
Library version 2.11.0

Hi,
I use both insights and larastan together, and they go in kinda conflict.
I have this function that returns a specific Model:

public function newUser(): User
{
    return User::create([...]);
}

This code returns a larastan error:

Method App\UseCases\TestUseCase::handle() should return App\Models\Users\User but returns Illuminate\Database\Eloquent\Model.

If I change the code like this:

public function newUser(): User
{
    /** @var User $user */
    $user = User::create([]);
    return $user;
}

I do not get larastan error, but insights advices me to comeback to previous code.

Any thoughts about it? How can I solve it? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions