Probably some of you have already noticed the changes in PHP code style settings. Putting the new UI look aside, I’d like to focus on new options and briefly explain their meaning and functionality. I hope you find them useful for making your code look more readable and closer to coding standards like PEAR or Zend.
PhpDoc Formatting (Settings|CodeStyle|PHP|PHP Doc)
There is a number of options which allow you to control the look of your PHP doc comments on reformatting:
- Align parameter names
Aligns the parameters prefixed with dollar ‘$’ sign.
- Keep blank lines
Tells if the blank lines (either put manually or inserted on previous reformatting) should be kept. Unchecking the flag will remove any blank lines which are not required by other options. Note: blank line here of course means an empty PHDoc line prefixed with a star ‘*’ character.
- Blank lines around parameters
Inserts blank lines around a group of parameter descriptions each starting with @param tag.
- Blank line before the first tag
Separates a description from the rest of PHPDoc. Note that if “Blank lines around parameters” is checked and the first tag is @param, the flag has no effect because there is already a blank line inserted by another option.
- Align tag comments
Aligns comments of @param tags and other tags. The two groups of tags (@param and other) are handled separately. Tags may have multiline comments in which case the whole comment will be aligned up to another tag or a blank line. Since blank lines appear meaningful for the alignment, it makes sense to keep them (make sure the “Keep blank lines” box is checked).
Code Alignments (Settings|Code Style|PHP|Other)
- Align key-value pairs
If checked, tells the formatter to align key=>value pairs on hash ‘=>’ sign. That’s the options you would most likely to check right now.
- Align consecutive assignments
If you have a group of assignments following each other without any gaps, they will be aligned on equals ‘=’ sign. By a gap I mean either a blank line, a comment or any other operator which is not an assignment (for example, echo).
Do you miss an option or have found a bug?
In both cases you are welcome to submit a feature request or a bug report at http://youtrack.jetbrains.com. And thanks in advance for any feedback!