New and Changed Formatting Options in PhpStorm 8

We continue to make improvements and add features to the PHP formatting engine based on your requests. Below is an overview of the new options and changes already included in PhpStorm 8 EAP.

Class fields and constants: Alignment and blank lines

There are two new options “Align fields in columns” and “Align constants” under “Class field/constant groups” section (“Wrapping and Braces“):


If the option “Align fields in columns” is selected, the following code:

will be formatted as follows (assuming that “Blank lines around fields” is 0):

but if you put a blank line between $id and $defaultPath fields, the final result will be:

That’s because $name and $id now form their own group separated from $defaultPath with a blank line. For example, if you set “Blank lines around fields” to 1, you will need to use at least 2 blank lines to separate groups. Otherwise the fields in the example above will be formatted as one group:

Class constants are processed separately from fields but the option “Align constants” works similar to “Align fields in columns“. Class constants also have their own setting to specify blank lines around them (0 by default):


Controlling indentation of code being commented out

When you comment out a chunk of code with line commenting action (Ctrl+/ or CMD-/), you can specify if you want line comment characters // to start at first column, for example:

or be indented with the code:

For the latter you need to deselect the option “Code commenting“/”Line comment at fist column” (“Other” tab). The option is on by default (line comments are created starting at first column):


Arrangement section rules

Sections are logical blocks of code enclosed in start/end comments. Optionally they may contain custom folding descriptors like “<edtior-fold>“…”</editor-fold>” or “region“…”endregion“.

You may add a special section rule like shown here:


This will bring up a dialog where you can specify a comment type (“section start” or “section end“) and a comment text which can be any text including manually defined “<editor-fold>” or “region“/”endregion” markers:


If the comment with the given text already exists in the code, it will not be generated again but possibly only moved according to the rules, if needed.

Consider the following example:


Rearranging the following code with the above rules:


will produce:


Note that class fields are not only grouped together but also enclosed in “region“…”endregion” comments which make the group collapsible.

Spaces within brackets: WordPress style

WordPress has a specific requirement for spacing inside brackets where simple values do not have spaces around them while variables and expressions must be surrounded with spaces as described here. There is a special option “Spaces around variable/expression in brackets” to meet this requirement:


Spacing around unary NOT (!)

Previously you could define spaces both around additive operators (+,-,++,–) and Not (!) unary operators. Now there are two separate options for spaces before and after the unary Not (!):


Note that the old option for spaces around unary operators no longer affects the unary Not.

Other changes

Align consecutive assignments” has been moved from “Other” to “Wrapping and Braces” panel but the option is still there:



All the new options can already be tried with the recent PhpStorm EAP build. Needless to say, we would be glad to hear back from you. If you have new ideas or find out that something doesn’t work as expected, please submit an issue in YouTrack. Thanks!

Develop with pleasure!
-JetBrains PhpStorm Team

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

6 Responses to New and Changed Formatting Options in PhpStorm 8

  1. Falk says:


  2. Keith Davis says:

    I love the new features, but there is a problem with Align fields in columns. We can’t have PHPDoc comments above them, and this is a required (Inspection) for us. So it appears we can’t use Align fields in columns AND PHPDoc comments for fields or am I missing something?

  3. Keith Davis says:

    Sorry, should have posted a sample:

    /** @var DATA_ProjectsTicketData[] */
    private static $aProjectTicketsDataByTicketsID = array();

    /** @var DATA_ProjectsApplicationData[] */
    private static $aProjectApplicationsData = array();

  4. Carsten Decker says:

    Nice improvements!

    Though I miss some options for JS as well – e.g. when having RequireJS or AngularJS injector arrays it would be nice if there at least were a possibility to let function parameter definition untouched if formatted manually – e.g.:



    ], function(



    // Write fancy code here …


    Currently (7.1.3) it is only possible to wrap them around in several ways. So when auto-formatting the structured look is gone…

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="">