barryvdh / laravel-ide-helper

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

Should generate |null for @property-read of morphTo relation #1373

Open Grldk opened 2 years ago

Grldk commented 2 years ago

Versions:

Description:

Suppose a model like this:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;

class Test extends Model
{
    public function owner(): MorphTo
    {
        return $this->morphTo();
    }
}

ide-helper generates the following line for the relation: * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $owner

expected: * @property-read \Illuminate\Database\Eloquent\Model|\Eloquent|null $owner

ide-helper generates |null for similar relations. (eg. BelongsTo)

I tested this with nullable columns for owner_id and owner_type, this does not make a difference.

snmatsui commented 6 months ago

+1

smpita commented 6 months ago

+1

Sergiobop commented 5 months ago

I think this one should be easy to fix

robclancy commented 5 months ago

It's only been 1.5 years...