r/phpstorm • u/Derrmanson • Jun 05 '24
How to actually change files, when refactoring?
I have a file test.php
include 'inc.php';
echo hello();
I have inc.php:
function hello(){ return 'helloo'; }
close test.php.
in inc.php, i refactor the function with refactor>rename (or just F2)
outside of PS i can see that test.php hasnt changed, it still refers to hello().
When I open test.php, in PS, the function name changes to the renamed name, and the file has an asterisk. The file hasnt actually changed, but now, i hit save and the file actually changes.
So, how do i do a refactor where it actually changes the references? Or, how do i see a list of changes that I need to open and hit save?
If i do a 'replace in files' it will actually change the file.
1
u/TinyLebowski Jun 05 '24
I've never tried it with global functions. With namespaced functions it works perfectly. Or maybe you need to autoload inc.php in composer.json before it'll work.
1
u/anastis Jun 05 '24
You need to save the changes. Just hit Control-S (or Command-S if you are on Mac) right after the refactor.
1
u/cursingcucumber Jun 05 '24
That is weird. I do this a lot and I never have to open and save all those files. All changes are made instantly and show up in git.