Laravel 7.x
IDE helper 2.7
$query = User::query();
$total = $query->count();
$query->where(...);
On any method called non statically on the model PHPStorm is showing the error [EA] '...::count(...)' should be used instead. ... Source: .../_ide_helper.php
However if the method is called statically Laravel throws an error
Not sure if this is the ide helper or the laravel plugin tho? Or maybe I've just done something wrong in my code?
Yes, this is a result of using ide-helper:generate.
Without ide-helper:
User::count()$query->count(), clicking on it brings you to \Illuminate\Database\Query\Builder::countWith ide-helper:
User::count(), clicking on it brings you into _ide_helper.php$query->count(), clicking on it brings you into _ide_helper.php[EA] …Now, if we would make the generated stub in _ide_helper not static, we would get
User::count(), clicking on it brings you into _ide_helper.php[EA] …$query->count(), clicking on it brings you into _ide_helper.phpIt's a trade-off 🤷♀️
Maybe the solution is to disable this inspection? The plugin authors do recognize already it's impractical in all cases, i.e. they have an exception for phpunit:

As you can see, I use it too but I don't find it much of an issue TBH. To me, slightly wrong inspection is better than having no autocomplete. The whole thing isn't perfect due to Laravels magic and ide-helper tries it best, well, to _help_. But I don't think it can ever be perfect.
That said: maybe there's a solution for fix all this, by using a different strategy to generate this stub files but I've no idea currently.
Thanks for the detailed explanation! I only reported the issue has I hadn't seen this before in previous versions of PHPStorm/IDE helper. Is it a new inspection?
It's just annoying having the yellow highlighting all through my controllers but I agree it's better to have the autocomplete. I just changed this to a weak warning so the error highlighting isn't as pronounced
Is it a new inspection?
Well, I've seen it for a long time but it's from the "EA Inspection plugin":
So it's a connection of different expectations from one 3rd party to another 3rd party plugin. Doesn't make the world easier 🤪
Well if it was all so easy half of us would be out of a job haha. Thanks much for your help and all the info!