barryvdh / laravel-ide-helper

IDE Helper for Laravel
MIT License
14.07k stars 1.16k forks source link

Incorrect type for nullable morph #1547

Open matysekmichal opened 3 months ago

matysekmichal commented 3 months ago

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');
}
mfn commented 3 months ago

Can you make a PR with tests?

matysekmichal commented 3 months ago

I'll prepare something.

matysekmichal commented 3 months ago

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