Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Incorrectly thinks a variable is global when renaming(Renaming a variable in a file renames it in every file in the project)
Incorrectly thinks a variable is global when renaming [message #1857193] Mon, 23 January 2023 17:44 Go to next message
Ken Pierce is currently offline Ken PierceFriend
Messages: 1
Registered: January 2023
Junior Member
I have a bunch of simple PHP files that produce reports, none of them include each other. Any global variables they use from includes is denoted by a
/** @var Type $name */
comment at the top of the file. Renaming a variable in one renames it in all of them because PDT thinks the variable is global. I never need to rename a variable across an entire project and it would be quite nice to have an option to limit the refactor to the current file, even if it has to be on the rename dialog. I first noticed this issue in the 12-2021 build. Updated to the 12-2022 build and the issue is still there. My current work around is find/replace because deselecting all the other files in the rename dialog is very time consuming.

I now have several files with variable names that make no sense because I did not notice this behavior until several weeks later.
Re: Incorrectly thinks a variable is global when renaming [message #1857200 is a reply to message #1857193] Tue, 24 January 2023 11:45 Go to previous message
Hassan Izhar is currently offline Hassan IzharFriend
Messages: 5
Registered: January 2023
Junior Member
I working on a huge code base written many years ago. We're trying to implement multi-threading and I'm incharge of cleaning up global variables (sigh!)

My strategy is to move all global variables to a class, and then individual threads will use instances of that class and the globals will be accessed through class instance and -> operator.

In first go, I've compiled a list of global variables using nm by finding B and D group object names. The list is not complete, and incase of static variables, I don't get file and line number info.

The second stage is even more messy, I've to replace all globals in the code base with classinstance->global_name pattern. I'm using cscope Change text string for this. The problem is that in case of some globals, their name is also being used locally inside functions, and thus cscope is replacing them as well.
Previous Topic:install issues
Next Topic:Internal Error When Debugging PHP Code
Goto Forum:
  


Current Time: Wed Apr 24 23:32:39 GMT 2024

Powered by FUDForum. Page generated in 0.03334 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top