apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.62k stars 841 forks source link

[PHP] Refactor->rename isn't detecting the property usage properly. #6719

Open terax6669 opened 9 months ago

terax6669 commented 9 months ago

Apache NetBeans version

Apache NetBeans 20 release candidate

What happened

When refactoring a class property a lot of incorrect usages are picked up.

image

It looks for any untyped occurrence of ->propertyName. Maybe it made sense before typing and namespaces existed in PHP but now it's just a problem, especially if you're renaming something generic like value. I think that searching for untyped potential matches needs to be optional. Either unchecked by default (as seen on screenshot, this can be a setting in options) or entirely disabled.

Searching in vendor packages also doesn't make sense in my opinion.

How to reproduce

Open a class file and try to rename a property by Refactor > Rename (Ctrl+R).

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 11

JDK

21.0.1

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

At first I was very confused and thought that it's simply broken. Upon further investigation I discovered what was really going on. I find this kind of behavior unintended, that's why I filed it as a bug, feel free to change it to feature if you think otherwise.

Since this window has a lot of empty space I propose to add a checkbox for it. image

Also the preview only appears after opening a file dropdown and selecting a specific occurrence. Can we please make it so that the file preview loads when you select a file (and jumps to first occurrence)? The message is confusing and made me think that the previews are broken, took me a while to figure out you had to go deeper. image

Are you willing to submit a pull request?

No

junichi11 commented 6 months ago

Could you also write an example code to reproduce it?