How can I place the auto-generated getter before the setter?
Hello,
I would like to generate my getters and setter placing the getter before the setter, does it is possible to? Currently, by default is exactly the opposite.
Thanks in advance,
Marcos
请先登录再写评论。
Hi there,
Settings | Code Style | PHP | Arrangement -- have a look at options there
http://blog.jetbrains.com/webide/2013/03/arrange-your-code-automatically-with-phpstorm-rearranger/
I've saw that and I've read the article but I've no idea how change the method order. Can you help me?
Well ... this is simple basically EMPTY class
This is the result of generating both setter and getter (in one go)
As you can see -- getter is placed BEFORE the setter method.
My current settings -- possibly you need to specify A-Z sorting order:
I understood what you said, but what I'm trying to do is configure the auto generator to generate the getters and setters methods in the same order of the properties but placing the getter before the setter. I believe it's possible, but I don't know how to achieve it (this interface is not intuitive).
I'm not 100% sure what you mean here. Could you please provide simple example (2-3 properties and their setters/getters) of how you want them to appear -- just to clarify the requirements?
I've this:
This is my goal:
Well ... I just reset those settings to their defaults .. and went to generate setters/getters.
If I do generate them one by one (first for $c, then for $b and then for $a), then they are kept in the same order .. but if I do bulk generation .. it gets screwed (setter before getter indeed and other side effects).
First for $c:
Then for $b:
Please note, that it makes difference (for whatever reason) how you generate them (how you call that generate command).
If you use "Code | Generate ... | Getters/Setters..." .. then result is a bit screwed.
But if you access it via Quick Fix menu (Alt+Enter on the field name) then it works fine:
There is a ticket or two about this -- hopefully it will be fixed in v7
Alt + Enter does not work on Mac (I believe the equivalent on Mac is [Command] + [N]). Anyway, there isn't a way to use the bulk generation keeping the property declaration order, right?
I do not know for sure what the shortcut is on Mac .. but you can check it (and modify if desired) yourself at "Preferences | Keymap" -- look for "Other | Show Intention Actions"
Well .. accordingly to the aforementioned ticket -- no (at least ATM as it simply does not work as intended right now). You can ask in that (or another, possibly more correct) ticket for clarification/details (I'm not a dev to tell you such details).
Ok, thanks so much for your time.