PhpStorm 2017.1 Help

Change Signature Dialog

Refactor | Change Signature
Ctrl+F6

Use the Change Signature dialog to perform the Change Signature refactoring in the PHP context.

Use the available controls to make changes to the function signature. Specify how the function calls should be handled. Optionally, select the calling functions that the added parameters and exceptions (if any) should be propagated to.

Click Refactor to perform the refactoring right away. Click Preview to see the potential changes prior to actually performing the refactoring. (These will be shown in the Find tool window.)

ItemDescription
VisibilitySelect the method visibility scope (access level modifier) from the list.
NameUse this field to modify the function name.
ParametersSee the description of the Parameters area.
Signature PreviewIn this area, the current function signature is shown. (The information in this area is synchronized with the changes you are making to the function signature.)

Parameters area

Use the Parameters area to manage the function parameters.

The available controls let you add new parameters, remove the existing ones, reorder the parameters and also propagate new parameters to the calling functions (see the descriptions that follow).

In addition to that, you can change the names of the existing parameters.

To start editing a parameter, just click it. Alternatively, use the Up and Down arrow keys to move to the parameter of interest and Enter to start modifying it.

ItemTooltip and shortcutDescription
/help/img/idea/2017.1/new.pngAdd
Alt+Insert
Use this icon or shortcut to start adding a new parameter.

Specify the name and default value in the corresponding fields. (The default parameter value is the value (or the expression) to be passed to the function in the function calls.)

You can also propagate the parameters you have added to the calling functions.

/help/img/idea/2017.1/delete.pngRemove
Alt+Delete
Use this icon or shortcut to delete the selected parameter.
/help/img/idea/2017.1/arrowUp.pngUp
Alt+Up
Use this icon or shortcut to move the selected parameter one line up in the list of parameters.
/help/img/idea/2017.1/arrowDown.pngDown
Alt+Down
Use this icon or shortcut to move the selected parameter one line down in the list of parameters.
/help/img/idea/2017.1/propagateParameters.png Propagate Parameters
Alt+G
Use this icon or shortcut to propagate the added parameters to the calling functions.

You can propagate the changes made to the function parameters to any function that directly or indirectly calls the function whose signature you are changing.

(There may be the functions that call the current function. These, in their turn, may be called by other functions. You can propagate the changes to any of the methods in such sequences.)

In the dialog that opens, select the functions you want the changes to be propagated to.

Note that only the selected calling functions and the function calls within them will be affected. That is, the default values will be added into other function calls.

Create and initialize class propertiesThe check box is available only in the PHP context when the Change signature refactoring is invoked from the constructor of a class.
  • When this check box is selected and you add a parameter, this parameter is initialized as a field. PhpStorm creates a protected field with the same name as this parameter and adds a line with the following assignment: $this-><parameter_name> = $<parameter_name>;
  • When the check box is cleared, a parameter is added without initialization.

For example, you have the following constructor:

class ChangeSignatureNewParam { function __construct() { $a = "Constructor in ChangeSignatureNewParam"; print $a; }}
If you invoke the Change signature refactoring from the __construct() method and add a new $q parameter, the result will depend on whether you select or clear the Create and initialize class properties check box:

The Create and initialize class properties check box is selected The Create and initialize class properties check box is cleared
class ChangeSignatureNewParam {private $q; function __construct( $q ) { $a = "Constructor in ChangeSignatureNewParam"; print $a; $this->q = $q; }}
class ChangeSignatureNewParam { function __construct( $q ) { $a = "Constructor in ChangeSignatureNewParam"; print $a; }}

See Also

Last modified: 19 July 2017