apache / apache/netbeans

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

Open
#6,719 1 comment 0 reactions 0 assignees View on GitHub
kind:bug needs:triage PHP
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 20 release candidate

### What happened

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

![image](https://github.com/apache/netbeans/assets/19204073/b5274911-c448-47b7-815b-27cfc65f5100)

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](https://github.com/apache/netbeans/assets/19204073/f578197d-b3c4-4997-97c2-f7a63424dbfc)

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](https://github.com/apache/netbeans/assets/19204073/4c3dc817-f635-429a-a246-8f4478080158)

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue through Refactor > Rename (Ctrl+R) on a PHP class property. Inspect how untyped property matches, vendor-package results, and file preview behavior are presented; done means incorrect usages are controlled or excluded and the preview appears at the expected selection level.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.