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 Project Explorer view. The following is a list of applicable PHP elements:
- Classes
- Interfaces
- Variables
- Methods
- Functions
- Constants
- Class Members
Note:
Ensure that you save any changes to the file before applying the refactoring feature.
Elements can either be renamed from within the editor itself if the in-place refactoring feature is activated (will not display a preview of changes) or from the Rename Element dialog.
Renaming Elements within the Editor
To rename an element within the editor:
- Ensure the 'Rename in editor without dialog' checkbox is marked in the Code Refactor Preferences page (accessible from Window | Preferences | PHP | Code Refactor).
- In the editor, place your cursor on the element to be renamed.
- From the menu bar select Refactor | Rename -or- right-click and select Refactor | Rename -or- press Alt-Shift-R.
All occurrences of the element are put in a frame and the Refactor popup is displayed.
- Type the new element name in the box.
All occurrences of the element name are automatically updated.
Note: To preview the changes before applying them, click the arrow in the right-hand corner of the Refactor popup and select Preview. - Click Enter to apply the refactoring.
A dialog is displayed prompting you to save the file before the refactoring is applied. - Mark the 'Always save all modified resources automatically prior to refactoring' checkbox so that the dialog will not be displayed again.
- Click OK.
The element will be renamed and all instances where that element is referenced will be updated to reflect the changes.
Renaming Elements through the Refactor Dialog