Book Image

PhpStorm Cookbook

By : Mukund Chaudhary
Book Image

PhpStorm Cookbook

By: Mukund Chaudhary

Overview of this book

Table of Contents (16 chapters)
PhpStorm Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Moving a method


There are two prerequisites to moving a method to some other class. One is the most common prerequisite: you should be clear about what you are doing. The other is that the method to be moved must be static. If it is not, PhpStorm will alert you by saying Move non-static method is not supported.

How to do it...

To move the method, perform the following steps:

  1. Just place the cursor over the method name, and access the Refactor option from the right-click context menu and move.

  2. You need to provide the name of the target class where you wish to move this method.

  3. You have the option to preview which occurrences will be affected by this change (movement).

  4. Once you are happy with the proposed results, you can refactor the method. The target class will now contain the method you just moved, as shown in the following screenshot: