More PHP Formatting Options and Bundled Code Styles for PSR-1/PSR-2 and Symfony2


You asked for it – and we responded. PhpStorm 5.0 includes several more PHP formatting options and fixes specifically targeted at PSR-1/PSR-2 and Symfony2 coding style support.

True/False/Null Constants (Settings | Code Style | PHP | Other)

The formatter is able to convert them both to upper and lower case depending on the chosen coding style. First you check the “Convert…” box and then select the type of conversion you want with radio buttons.

Blank Line Before Return Statement (Settings | Code Style | PHP | Other)

This rule is specific for Symfony2 coding style. It inserts a blank line before every return statement unless the return statement resides in a simple block:

Keep ‘)’ and ‘{‘ on one line (Settings | Code Style | PHP | Wrapping and Braces | Function declaration parameters)

This option is needed to implement the following rule which can be found, for example, in Zend and PSR-1 coding styles: “When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them” (an extract from PSR-1). Here is a short sample:

class ClassName
    public function myFunction(
    ) {
        // method body

Bundled Code Style Settings for PSR-1/PSR-2 and Symfony2

Instead of manually checking every formatting option, you may just apply a predefined code style for PSR-1/PSR-2 or Symfony2 similar to previously introduced PEAR, Zend and Drupal:

If you find any kind of problems with the new options or PSR-1/PSR-2 and Symfony2 coding style support, please submit a bug report in YouTrack. We’ll do our best to fix these problems.

Develop with pleasure!
– JetBrains Web IDE Team

Comments below can no longer be edited.

18 Responses to More PHP Formatting Options and Bundled Code Styles for PSR-1/PSR-2 and Symfony2

  1. Alexander Makarov says:

    November 6, 2012

    Thanks! Love it.

  2. Rafi B. says:

    November 7, 2012

    Is it possible to create new custom “bundled code styles” ourselves ?

    • rustam.vishnyakov says:

      November 7, 2012

      There is an API for predefined code styles. So it is possible to make a plug-in which would provide a bundled style.

  3. markux says:

    November 8, 2012

    Thanks! PS: what is your color scheme into screenshot?

  4. Ben VanEvery says:

    November 16, 2012

    Yes! Yes! Yes!! Thank you!

  5. Onno Lissenberg says:

    November 23, 2012

    How do I get this for IntelliJ IDEA 11?

    • rustam.vishnyakov says:

      November 26, 2012

      it should be available in plug-in repository. I think PHP plug-in build 121.390 is compatible with Intellij IDEA 11 (build 118.430 or later).

      • Onno Lissenberg says:

        November 26, 2012

        I got the IDEA 11 build 117.963 (Mac version) and no updates available, where can I get the latest version?

        • rustam.vishnyakov says:

          November 26, 2012

          Sorry, I think I misguided you. It looks like the build 118 is actually an early EAP of Intellij IDEA 12. So it means that the new PHP plug-in is available only for version 12 which is about to be released.

  6. Onno Lissenberg says:

    November 26, 2012

    I bought version 11 in September, is version 12 going to cost me anything? And using the version of the plugin that you mentioned freezes version 11 on start up, luckily I could roll-back the changes without too much trouble, it was my bad, I skipped the IDEA version part 😉

    • rustam.vishnyakov says:

      November 28, 2012

      As far as I know our licensing agreement gives you a possibility for free upgrades. So I think you will be able to upgrade from version 11 to version 12 at no cost. You can also post any kind of questions regarding licensing terms at

    • rustam.vishnyakov says:

      December 5, 2012

      unfortunately my information regarding a possibility of a free upgrade from version 11 was wrong. I’ve just got a reply from our sales: “Only personal v11 licenses, purchased on or November 7 qualify for a free
      upgrade.” Sorry for that. In any case regarding upgrade/purchase possibilities please contact our sales department.

      • Onno Lissenberg says:

        December 10, 2012

        Yes, that was disappointing. Still purchased it though and it works nicely. The UI could maybe improve a little by naming the sub-styles (for each language option, e.g. name the applied PHP style as PSR-1/PSR-2), just a thought.

        Awesome product, thanks.

  7. Peter says:

    December 5, 2012

    Is there a difference between PSR1/PSR2 and Symfony2 coding styles? According to the Symfony website: “Symfony follows the standards defined in the PSR-0, PSR-1 and PSR-2 documents.”


    • rustam.vishnyakov says:

      December 5, 2012

      Yes, there is. For example, “Add a blank line before return statements, unless the return is alone inside a statement-group (like an if statement)” is not required by PSR1/PSR2.