barryvdh/laravel-ide-helper

Default values as enums cases

d8vjork opened this issue · 0 comments

Versions:

  • ide-helper Version: 2.12.3
  • Laravel Version: 10.19.0
  • PHP Version: 8.2.8

Description:

In case we want to add a default value using an enum typed argument on a model query scope like so:

<?php

class MyModel extends Model
{
    public function scopeHasAbility(Builder $query, Authenticatable $user, ?CrudAction $ability = CrudAction::Read)
    {
        // code here...
    }
}

This will run fine in PHP 8+ but IDE helper models docblock generator command will complain with the following error:

image

Error comes from this line:

$default = "'" . trim($default) . "'";

Steps To Reproduce:

  • Add code from description
  • Run php artisan ide-helper:models -w