PhpStorm 2022.3 Help

Move Class Dialog

The dialog opens when you position the caret at the name of the class in the editor and invoke the refactoring.

PhpStorm supposes that the namespaces in your project are arranged in compliance with the PSR0 standard and enforces you to retain the folder structure and the namespace hierarchy in accordance with this standard when moving classes among namespaces.

When you specify a namespace to move a class to, PhpStorm automatically updates the Target Destination Directory field, which shows the path to the folder where the file that implements the class in question will be stored.

Item

Description

Move class <class name> to namespace

When the dialog opens, this field shows the namespace to which the class belongs. Specify the fully qualified name of the target namespace. Depending on your use case, this can be:

  • A new namespace under the current namespace in the format <current namespace>\<new namespace>.

  • Another subordinate namespace under the current parent in the format <path to immediate parent namespace>\<namespace to move the class to>.

  • An existing or a new namespace under another parent namespace in the format <path to another root namespace>\<namespace to move the class to>.

Use only backslashes \ as namespace separators.

Target destination directory

When the dialog opens, the field shows the path to the folder where the file that implements the class to move is currently stored.

The path is displayed in the following format:

...\<project root>\<current namespace folder relative to the project root>

The path is updated automatically as you specify the namespace to move the class to. However, if you are going to move a class to a non-existing namespace under another parent namespace, PhpStorm will not suggest the proper folder unless you appoint a root folder for your namespace structure by marking the relevant folder as Sources on the Directories page of the Settings dialog (Ctrl+Alt+S). See Directories for details.

Do one of the following:

  • Accept the preselected path displayed in the field.

  • Choose another path from the list. All of them are evaluated from the namespace root or from the current directory, so it is safe to choose any of them.

  • Click the Browse button and select a folder in the dialog that opens.

  • Press F2 and edit the preselected path. Keep in mind that this may cause problems with automatic loading in the future.

Search in comments and strings

If this checkbox is selected, PhpStorm will look for references to the class to be moved within comments and string literals in source code files.

Search for text occurrences

If this checkbox is selected, PhpStorm will look for references to the class to be moved within documentation, HTML, JSP, various configuration files (for example .yml), and other files included in your project.

Last modified: 21 July 2022