X

An Oracle blog about NetBeans for PHP

Improved Type Renaming

Hi all! Today we would like to show you brand new renaming feature for next NetBeans release.

Most of you definitely use common standard that every class is in its own file and the file name is the same as the class name. It means that if you have class Foo it will surely be in a file named Foo.php. But when you rename that class you surely want to rename its file as well. And NetBeans, finally, allows you to do that automatically :-) Just check one checkbox during refactoring process and that's all.

So here are some screenshots:


Right click on the class name and invoke Refactor -> Rename....

Improved Type Renaming

Type new name and check Rename Also File With the Declaration. checkbox.

Improved Type Renaming

Confirm refactoring and look at new file name :-)

Improved Type Renaming

And that's all for today and as usual, please test it and if you find something strange, don't hesitate to file a new issue (product php, component Refactoring). Thanks a lot!

Join the discussion

Comments ( 7 )
  • guest Wednesday, March 20, 2013

    Good feature. Will the checkbox automatically be checked the next time a refactoring occurs?


  • Ondrej Brejla Wednesday, March 20, 2013

    No, it has to be rechecked.


  • Robert Sandgren Wednesday, March 20, 2013

    Will it use lower case filename if the previous is it?

    autoloader with strtolower($class) in it...


  • Ondrej Brejla Thursday, March 21, 2013

    No, the name of the file is exactly the same as for class. But it's a good enhancement. You can write it to our bugzilla [1]. Thanks!

    [1] http://netbeans.org/bugzilla/enter_bug.cgi?product=php


  • guest Saturday, March 23, 2013

    I do back the request Robert made.

    Names of classes and namespaces are not case-sensitive in PHP.

    Thus you should not rely on the class name being given in the "right" casing.

    If this is your convention, better be aware that you are introducing a new principle into the language that has never been a part of the language definition and never will be.

    In PHP there is by definition no difference in writing "new foo()" instead of "new Foo()" and no development environment will warn or force you to prefer the one over the other.

    What would be even better though is a feature for refactoring namespaces.

    My colleagues have asked me several times now for that now because it would be so useful.

    However: this includes that you would need to assume a certain behavior of the auto-loader.

    So to implement this feature properly you would have to add some project-wide settings that describe what your auto-loader does. Usually that would be (at least) a "root-directory" and a "style of file- and folder names" (case-sensitive or not).

    But since you can have multiple auto-loaders within the same project you may want to bind those settings to a namespace.


  • Ondrej Brejla Wednesday, March 27, 2013

    > be aware that you are introducing a new principle into the language

    Definitely not. Classes with the same name as files (including casing) is a widely used style.

    But I'll try to make some improvements. To let NB remember the last used option (rename file too or not) and add a checkbox to rename file with lowercases.


  • Ondrej Brejla Wednesday, March 27, 2013

    I just pushed that changes, so that lowercase option will be in the dev build soon.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services