Moving a member variable to some other class is simple but quite important from an architectural point of view. A variable usually denotes an attribute from the real world. So, if you planned sugar for PizzaDish
, you will definitely and very quickly need to move the sugar from PizzaDish
to some other dish, say Cookie
. Just like methods, you can only move the static members to some other class.
Select Refactor from the right-click context menu, and then select Move.
If the current member variable to be moved was private in the current class, the Move operation will convert the member to public.
PhpStorm warns you before performing the move, as shown in the following screenshot:
Tip
Wherever you put the sugar, you should always try to use the syntactic sugar because it eases a bit of the documentation load.
PhpStorm said "Your knowledge level has been increased to 200 percent". You must say "Great!"... 200 percent... how? You already knew how to copy or cut and paste...