Renaming Elements

 

This procedure describes how to rename a PHP element and ensure that all references to that element are updated.

All PHP Elements can be renamed and refactored from within the editor window. The following is a list of PHP elements:

Note:

Ensure that you save any changes to the file before applying the refactoring feature.

 

 

Instructions on how to complete a procedure

To rename an element using the Refactoring feature:

  1. In the editor window, right-click the required element and select Refactor | Rename -or- press Alt-Shift-R - or- if applicable, right-click the element in PHP Explorer view and select Refactor | Rename.
    The Rename dialog box will be displayed. The name of the dialog will be dependent on the element type.

  1. Enter the element's new name. You must enter a valid name for the required element - i.e. one that starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

  2. Check the "Update textual occurrences in comments and strings" box if you want the element's name to be updated in all comments and strings where it is referenced.
    This will force you to preview the changes before applying them.

  3. Click OK to apply your changes or click Preview if you want to see a preview of the changes that this refactoring will create.

  4. If you clicked preview a preview window will open with a changes tree showing all the changes which will be made to reflect the rename of the element.
    The changes will be listed according to the context within which they appear. You can therefore expand the nodes to see all changes within particular files, classes or functions.

  5. Use the Next / Previous Change arrows to scroll through all possible changes.
    Unmarking the checkboxes next to the changes will cause those changes not to take effect.

Note that if changes will be made in other files which reference the element being refactored, the changes will also be listed here under the file name.

  1. The changes to be applied will be displayed in the bottom pane.
    You can scroll through the different changes using the scrolling arrows:

  2. Next / Previous Difference scrolling arrows - Scroll through changes to be applied within the element selected in the top pane.

  3. Next / Previous Change scrolling arrows  - Scroll through all changes to be applied. If you unmarked changes in the top pane, these will not be displayed when using these arrows.

  1. Once you are satisfied with the changes, click OK.

The element will be renamed and all instances where that element is referenced will be updated to reflect the changes.

 

 

Related Links

Related Links:

Refactoring

Working with the Refactoring Feature

Using Refactoring

Renaming Files

Organizing Includes

Refactor Menu