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