PhpStorm 2022.2 Help

Extract Interface Dialog

Refactor | Extract Interface

For more information on how to use Extract Interface in PhpStorm, see the extract interface section.



Interface Name

In this field, specify the name of the interface to be created. By default, PhpStorm suggests the name of the current class from which the interface will be extracted. Update the name otherwise PhpStorm will report an error and the refactoring will no start.

Replace class reference with interface where possible

  • When this checkbox is cleared, PhpStorm just creates an interface in a separate file and marks the source class as implementation of the new interface.

  • When the checkbox is selected, PhpStorm creates an interface and attempts to replace references to the source class with references to the interface in PhpDoc comments and parameters of methods. The proposed changes are compulsory displayed in a Refactoring Preview pane of the Find tool window. To have the interface extracted and the proposed changes applied, click Do Refactor.


In this drop-dow list, specify the namespace the new interface will belong to. By default, the namespace of the source class in selected.

Target destination directory

Specify the folder to store the dedicated file created for the new interface. By default, the field is read-only and shows the folder that corresponds to the namespace to which the interface will belong according to the PSR0 standard.

To have the class with the interface stored in another folder, click F2 and specify the folder of your choice.

Members to form interface

This table shows all the methods detected in the current class. To have a method moved to the interface specified in the Move Member To Class, select the checkbox next to the method.


In this area, specify how you want PhpDoc comments treated. The available options are:

  • As is: select this option to have the documentation left where it is in the source class.

  • Copy: select this option to have the inline documentation copied to the extracted interface without removing it from its current location.

  • Move: select this option to have the inline documentation moved to the extracted interface and deleted from its current location in the source class.

Last modified: 17 March 2022