The Extract Field refactoring declares a new field and initializes it with the selected expression. The original expression is replaced with the usage of the field.
To extract a field using the dialog box
- In the editor, select the expression or variable to be replaced with a field, or just place the cursor within such an expression or variable declaration.
- In the main menu, or the context menu of the selection, choose Refactor | Extract Field , or press Ctrl+Alt+F.
- In the Expressions pop-up menu, select the expression to be replaced. Note that PhpStorm highlights the selected expression in the editor.
- In the Extract Field Dialog dialog that opens, specify the type and name of the new field.
- To automatically replace all occurrences of the selected expression (if it is found more than once), select the option Replace all occurrences.
- Click OK to create the field.
Last modified: 10 December 2014