plugin
plugin copied to clipboard
[Bug]: Local Scopes are always shown as "unused"
Bug description
Using PhpStorm 2022.1.1, Laravel 9 and Laravel idea 5.4.
When I create a local scope in a model and use it in a controller or anywhere in the code, it is properly recognized by the plugin and I can ctrl+click the usage of the scope to navigate to its definition (this is great !). However, the method itself is always greyed out and recognized as unused by PhpStorm.
I'm not sure if it's a bug or a known limitation, but this is kind of dangerous, because it makes you think that you can safely delete apparently unused scope, and break your code (Yes, that happened to me...)
Thanks for your help !
Plugin version
5.4.0.221
Operating system
Windows
Steps to reproduce
- Create a scope, for example :
public function scopeActive(Builder $query): void
{
$query->where('active', 1);
}
- Use it somewhere :
public function index()
{
return User::active()->get();
}
- Generate the Eloquent helper code.
The scope is recognized :

But marked as unused :

Relevant log output
No response
Important feature for code refactoring and finding method uses
Hi @adelf : Sorry to harass you but it is an important feature for us and it seems like others have a need for this.
Could you let us know if this is a known limitation and if there's a chance you could improve it ?
PS : I just confirmed it still behaves the same with the latest version of the plugin (5.7.3.221) and phpstorm 2022.2
Thanks
Let me check.
Looks like I managed to make it work as needed.
Awesome, thanks for taking the time to look into it !
I made it configurable and turned it off by default(it might use too much CPU, but I'm not sure 100%).
Preferences | Languages & Frameworks | Laravel Idea | Eloquent