laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Incorrect type for nullable morph

Open matysekmichal opened this issue 1 year ago • 3 comments

Summary

Command php artisan ide-helper:models do not consider nullable morphs, and recognize such properties as \Illuminate\Database\Eloquent\Model|\Eloquent. Instead it should be of type \Illuminate\Database\Eloquent\Model|\Eloquent|null.

// migration

Schema::create('examples', function (Blueprint $table) {
    $table->nullableMorphs('column');
});
// class Example

public function column(): MorphTo
{
    return $this->morphTo('column');
}

matysekmichal avatar May 16 '24 07:05 matysekmichal

Can you make a PR with tests?

mfn avatar May 16 '24 08:05 mfn

I'll prepare something.

matysekmichal avatar May 16 '24 13:05 matysekmichal

https://github.com/barryvdh/laravel-ide-helper/pull/1549

matysekmichal avatar May 17 '24 20:05 matysekmichal