Skip to content

[Bug]: A model's explicitly defined public static function create is ignored #1313

@KSneijders

Description

@KSneijders

Bug description

Report

Models which have an explicit public static function create defined seem to be ignored.

We're using MagicLink for a project which overwrites the public static function create function. But after running Generate helper code everywhere where we use this function we get the following:

Image

Expected behaviour

I'd expect the autocomplete for this model (at least when calling SomeClass::create(...) directly, to be the arguments I've defined above.

Actual behaviour

This is the autocomplete from PHPStorm:
Image

Which is caused by the generated helper code:
Image

Plugin version

11.5.0.253

Operating system

Windows 11

Steps to reproduce

  1. Place the model below in a laravel project:

    namespace App\Models;
    
    use Illuminate\Database\Eloquent\Model;
    
    class SomeClass extends Model
    {
        protected $fillable = [
            'max',
            'min',
        ];
    
        public static function create(int $max, int $min): self
        {
            return new self(['max' => $max, 'min' => $min]);
        }
    }
  2. Run: "Generate helper code"

  3. Write SomeClass::create() and look at the autocomplete.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions