phpvisual-studio-codephp-cs-fixer

Leave empty line breaks PHP CS Fixer


In my code I prefer to have more than a single line break between methods inside a class to make browsing code a little easier, and I've tried a bunch of rules that sound related to keeping/removing white space, but I cannot find a rule to ignore empty line breaks.

Take the following snippet

<?php

class Foo
{
    public function __construct()
    {
        //
    }





    /**
     * Undocumented function
     *
     * @param [type] $param1
     * @param [type] $param2
     */
    public function bar($param1, $param2)
    {
        //
    }
}

php-cs-fixer will remove the white space between the two methods like so

<?php

class Foo
{
    public function __construct()
    {
        //
    }

    /**
     * Undocumented function
     *
     * @param [type] $param1
     * @param [type] $param2
     */
    public function bar($param1, $param2)
    {
        //
    }
}

I find this harder to read when scanning through a class file, so I'd like to tell php-cs-fixer to leave the empty line breaks alone. Is this possible?

I've tried setting no_extra_blank_lines to an empty array, or to false as this sounded like the right setting, but it doesn't appear to have any affect.

FYI I'm using VS Code with this extension: https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer


Solution

  • After leaving this for a couple of days, I've come back to it and managed to find the appropriate rule.

    If I change method_separation => false the line breaks are left in tact in class files.