plugin icon indicating copy to clipboard operation
plugin copied to clipboard

[Bug]: Local Scopes are always shown as "unused"

Open nicolus opened this issue 3 years ago • 5 comments

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

  1. Create a scope, for example :
public function scopeActive(Builder $query): void
{
    $query->where('active', 1);
}
  1. Use it somewhere :
public function index()
{
    return User::active()->get();
}
  1. Generate the Eloquent helper code.

The scope is recognized : image

But marked as unused : image

Relevant log output

No response

nicolus avatar May 25 '22 14:05 nicolus

Important feature for code refactoring and finding method uses

inovar-tecnologia avatar Jun 02 '22 14:06 inovar-tecnologia

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

nicolus avatar Aug 02 '22 07:08 nicolus

Let me check.

adelf avatar Aug 02 '22 11:08 adelf

Looks like I managed to make it work as needed.

image

adelf avatar Aug 02 '22 13:08 adelf

Awesome, thanks for taking the time to look into it !

nicolus avatar Aug 02 '22 13:08 nicolus

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

adelf avatar Nov 17 '22 13:11 adelf