Move Static Member refactoring for PHP in PhpStorm

With the new Move Static Member refactoring in the PhpStorm 7 EAP, we can move static fields and methods to another type. For example when classes contain static methods that are nothing but utility methods, we can move them into a separate type.

The PHPExcel open source project has such a class: PHPExcel_Cell. It contains logic for cells in a spreadsheet as well as several utility methods that convert cell coordinates. Let’s move some of them into a new class: PHPExcel_CellUtils. In the editor we can place the caret on any static method and invoke the Move Static Member refactoring by pressing the F6 key.

After searching the type we want to move these members to, select the methods and fields that should be moved. We can refactor immediately, or use the Preview button to see the changes that will be performed.

PhpStorm will search all references of these static members and make sure they are updated. The IDE will notify us about potential problems as well. Using the Preview button, we can clearly see all occurrences where the methods selected earlier are used and where the Move Static Member refactoring will apply. Click Do Refactor to perform the changes.

Give PhpStorm 7 EAP a try and let us hear your thoughts in the issue tracker, the comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

This entry was posted in Cool Feature, Early Access Program and tagged , , . Bookmark the permalink.

One Response to Move Static Member refactoring for PHP in PhpStorm

  1. Pingback: PhpStorm 7.0リリース | JetBrains ブログ

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">