Open lk77 opened 2 months ago
@lk77 Could you let me know if you tried to define your factory implementation? like the following :
/** @use HasFactory<YourModelFactory> */
use HasFactory;
note: don't forget to replace YourModelFactory
with the real factory class for this model.
I tried that solution, and it does not work, the only solution i have is to copy paste the "@method static" line from _ide_helper_models.php to the actual model
and it seems it's the same with all static methods like query(), they do not work with the -M option
i guess there is some sort of "precedence" calculation between ide-helper annotations, and laravel annotations, or type inference of some sort
edit :
i removed all annotations from laravel manually in vendor, just to test, and now i can't ctrl+click anymore, but it still does not find the annotations in _ide_helper_models.php
@khaled-sadek I'm having the same problem and the suggested fix didn't work. I tried the comment hint with the full path to the factory class and just the class alone (e.g. WorkSiteFactory
and Database\Factories\WorkSiteFactory
).
I just refactored to use mixins and really prefer it, but this makes writing tests incredibly annoying. Might switch back if there's not fix for this. Thanks!
@madebycaliper
i have something like that :
/**
* @method static \Database\Factories\User\UserFactory factory($count = null, $state = [])
*
* @mixin IdeHelperUser
*/
class User extends Authenticatable
Versions:
Question:
When i'm using ide-helper:models -M, the HasFactory::factory() method is not recognized properly, it works fine without the -M, somehow, using a mixin cause this line :
to not be recognized by phpstorm, which cause "polymorphic calls" warnings, because phpstorm expect a generic Factory instance, and not the real factory for the model,
do you have any idea why that is ?
thanks.