Could not find any information on this issue.
- I’m using PhpStorm’s Laravel Idea plugin for my Laravel projects.
- All of our models
use IlluminateDatabaseEloquentConcernsHasUuids;
, and our migrations use$table->uuid('id')->primary()
. - All of our foreign keys are
char(36)
as our migrations use$table->foreignIdFor(ParentModel::class); // 'parent_model_id' char(36)
- When I run “Code Generation”
⌘⇧,
the resulting helper files (found in “vendor/_laravel_idea/ide_helper_models*.php”) hint that the model property type isint|null
:
/**
* ...
* @property int|null $parent_model_id
* ...
*/
class ChildModel extends Model {}
Laravel Idea assumes the primary keys will be an int, and that’s rarely the case in modern apps. This results in PhpStorm providing the wrong type-hint, and running PHPStan throws a type-mismatch when doing any comparisons or testing. In order to kludge fix this, I manually add my own phpdoc directly on my model. Though this has the effect of hampering PhpStorm, because now when I cmd+click into the property throughout my app, it will direct me to my PHPDoc declaration and not intelligently find the symbol references like it normally would.
Is there a setting somewhere to have Laravel Idea look at the actual migration or model definitions to set the type?
2