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

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

Open Grldk opened this issue 3 years ago • 4 comments

Versions:

  • ide-helper Version: 2.12.3
  • Laravel Version: 9.25.1
  • PHP Version: 8.1.x

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.

Grldk avatar Sep 09 '22 15:09 Grldk

+1

snmatsui avatar Mar 28 '24 00:03 snmatsui

+1

smpita avatar Apr 05 '24 20:04 smpita

I think this one should be easy to fix

Sergiobop avatar Apr 16 '24 10:04 Sergiobop

It's only been 1.5 years...

robclancy avatar May 01 '24 01:05 robclancy