Category Archives: php

php (category auto created by Wordpresser)

PHPStorm fails refactors in symlinked files

Yesterday, while programming a solution that will automatically build some of my videos, I faced an unexpected problem with JetBrains PHPStorm v19.2.

The issue was (and is) that doing a “refactor > rename” of any method’s parameter would not work. The IDE’s “preview” would correctly show the changes that should happen, but upon confirmation, by pressing the ENTER key, while the parameter name would change, its usages would not, so the code would not work, because of the new unknown identifiers.

This would only happen with identifiers corresponding to method parameters, which are “signature” elements, together with the method’s name and its return type.
After some head scratching, I understood what is the issue: the file corresponding to the class of the method being edited, is available to the project not in a “real” directory, but via a “symbolic link”, which a Microsoft Windows file system’s feature that allows, among other possibilities, to make the same single folder seemingly available at many different points. It happens that PHPStorm will NOT change signatures for methods in files, which are not directly available to projects. If the file is available to the project as a real direct, then “refactor > rename” works; if the file is in a symlink, it does NOT.

Problem understood. This is annoying, but now understandable.

I cannot say for sure that is new in the latest version of PHPStorm (v19.2, in August 2019), but I don’t remember having faced the issue in the past, and I’ve used symlinks before.

I tweeted about the mysterious issue here:

“@JetBrains I think you created a bug in PHPStorm 19.2
Try to refactor > rename any param in a method’s param list. You will see a CORRECT preview in the body, but when ENTER is pressed, the param is renamed yet the body keeps the old identifiers.”

Then, when I understood the problem, I replied to myself here:

“Replying to my own problem: I found the issue is due to symbolic links (file system symlinks) in Windows. The project in question uses a folder which is a symlink to a real directory. Refactor of signature elements (such as params) in files at that location will fail.”