Are there any tools which support refactoring PHP code (renaming variables, extracting methods, finding method references, ...)? Thank you.
PDT for Eclipse supports some basic refactoring (that I know of). You can rename classes and have them automatically renamed when they're referenced, and I think you can even move files and have their include/require references changed, too.
Maybe it's just because I'm still getting comfortable with the concepts of refactoring but I don't like having a tool do it for me.
I still prefer to do most refactoring manually because it forces me to slow down and really think about what I'm moving around and why.
The NetBeans IDE has some refactoring capability but it doesn't always seem to work. I am however using 6.1 with early PHP access. I expect 6.5 to have better refactoring capabilities with PHP.
There is no refactoring support for PHP in Netbeans 6.5, its coming in future version though.
PDT eclipse plugin also does not support refactoring.
Aptana does not support refactoring either. I couldn't get goto definition to work either.
I end up using search and replace currently. I too would like at least rename function support.
rephactor is an automatic refactoring tool. It is still a bit incomplete, but it has a few basic refactorings.
Else, a good test suite is really the best tool for refactoring, you can have.
Still my favorite refactoring tool is good ol' EditPlus in combination with Total Commander's super fast file search. (Hint: Alt+F7) I totally agree with Mark Biek's reply that you want to have full control over what is replaced where and when.
Whenever i have to do a some refactoring, i create a list in total commander of the files i want to alter by either searching with the built-in function or just by selecting them, and then i drag them all to EditPlus
Editplus can search & replace through the current file, a selection or all opened files using normal text matching, regex matching or multiline matching. It really gives you full control :)
Also, what comes in handy for code refactoring is EditPlus's Macro Recorder (Ctrl + Q to start recording macro 1-9 and Alt + 1-9 to playback a macro).
Once you get the hang of it, you know you can just search for a variable, ctrl + shift + (home || end || arrow keys) through your code, delete, copy/paste and use al that keyboard wizardry to like, for instance, convert a CSV file into a bunch of SQL queries within 30 seconds.
As far as I know, the only IDEs that has any significant Refactoring support for PHP are Zend Studio from the makers of PHP and the Eclipse PHP plugin. Though the features are very basic. Nothing that I know of has the features of products like Resharper for C# etc.
I read that the IDE Delphi for PHP will have refactoring capabilities in the release codenamed Crocodile, scheduled for early 2009. See this link for details.
I personally prefer PHPEclipse IDE as my primary development tool. But I really miss basic "replace everywhere in the project" refactoring there.
But very simple find/sed command can solve it easily:
find . -type f -name "*Controller.php" -print0 \
| xargs -0 sed -i 's/string1/string2/g'
So using this intelligently you can find references, renaming, removing and make any sort of manipulations with the source code.
BTW: you even can not remember all this parameters and attributes - just type it once and then call it through reverse-i-search.
Hope this helps.
Scisr is a simple, standalone refactoring tool for PHP.
I know this is an old question, but since it's one of the best rundowns of PHP refactoring tools, I thought I would add my new project to the list.
A lot of my design goals sprung out of the inadequacies of other items mentioned here - they are tied into certain IDEs, or try to dictate your testing practices, or require a whole bunch of rote manual labor. I am hoping to create an overall better experience in Scisr. It's simple to install and run. It tries to be clever, but not too clever. It does the tasks that I have found to lend themselves best to automation. Enjoy!
Try Web IDE from IntelliJ. It's in the EAP stage (alpha/beta) now, but I use it as the only IDE for several months, so it's stable and very good.
Just published an article about the next release of Delphi for PHP where you can see the refactoring engine in action.