{"id":18958,"date":"2013-03-11T16:56:20","date_gmt":"2013-03-11T16:56:20","guid":{"rendered":"https:\/\/blog.jetbrains.com\/webide\/?p=5831"},"modified":"2024-01-09T15:05:59","modified_gmt":"2024-01-09T14:05:59","slug":"refactoring-for-classes-in-phpstorm-6-move-class","status":"publish","type":"phpstorm","link":"https:\/\/blog.jetbrains.com\/fr\/phpstorm\/2013\/03\/refactoring-for-classes-in-phpstorm-6-move-class","title":{"rendered":"Refactoring for classes in PhpStorm 6: Move Class"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-5832 alignleft\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-12.png\" alt=\"\" width=\"327\" height=\"281\" \/>Moving code around is an essential part of application design and maintenance, but it may become a tedious task in modern code utilising namespaces and the PSR0 file layout convention.<\/p>\n<p><em>Move Class<\/em> refactoring is a reliable tool that will remove the burden of maintaining project consistency and allow you to use move as a simple atomic action, allowing you to keep your focus on the design decisions, that is especially important as a part of complex high-level refactorings.<\/p>\n<p><!--more--><\/p>\n<p>To invoke this refactoring, place the caret on the target class and press <strong>F6<\/strong> (or select <em>Refactor | Move&#8230;<\/em>):<\/p>\n<p style=\"text-align: center\"><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-move_class_initial_state.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-5836 aligncenter\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-5.png\" alt=\"\" width=\"622\" height=\"419\" \/><\/a><\/p>\n<p>The <em>Move Class<\/em> dialog appears:<\/p>\n<p style=\"text-align: center\"><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-move_class_dialog.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-5834 aligncenter\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-6.png\" alt=\"\" width=\"495\" height=\"259\" \/><\/a><\/p>\n<p>Here you should update the namespace name.<em> Target directory field <\/em>will be changed automatically:<\/p>\n<p style=\"text-align: center\"><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-move_class_dialog.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-5835 aligncenter\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-10.png\" alt=\"\" width=\"502\" height=\"259\" \/><\/a><\/p>\n<p>If you want to change the namespace for the class but don\u2019t want to move file to another directory, disable the checkbox &#8216;<em>Move class to a new file<\/em>.&#8217;<\/p>\n<p>That&#8217;s it! All references to the class will be updated with auto-imports where possible and with fully qualified names otherwise.<\/p>\n<p style=\"text-align: left\">Here&#8217;s see the result of the refactoring:<\/p>\n<p style=\"text-align: center\"><a href=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-move_class_before.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-5833 aligncenter\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2013\/03\/webide-9.png\" alt=\"\" width=\"481\" height=\"436\" \/><\/a><\/p>\n<p>Don\u2019t waste your time on routine, monotonous work &#8211; leave it to your PhpStorm IDE!<\/p>\n<p>Please share your feedback in the <a href=\"http:\/\/devnet.jetbrains.com\/community\/wi\" target=\"_blank\" rel=\"noopener\">forum<\/a> and report any bugs or feature requests to our <a href=\"http:\/\/youtrack.jetbrains.com\/dashboard\/WI?\" target=\"_blank\" rel=\"noopener\">issue tracker<\/a>.<\/p>\n<p><em>Develop with pleasure!<\/em><br \/>\n<em> &#8211; JetBrains Web IDE Team<\/em><\/p>\n","protected":false},"author":74,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","categories":[808,907],"tags":[228,45,195],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/phpstorm\/18958"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/phpstorm"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/types\/phpstorm"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/users\/74"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/comments?post=18958"}],"version-history":[{"count":1,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/phpstorm\/18958\/revisions"}],"predecessor-version":[{"id":432213,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/phpstorm\/18958\/revisions\/432213"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/media?parent=18958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/categories?post=18958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/tags?post=18958"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/fr\/wp-json\/wp\/v2\/cross-post-tag?post=18958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}