Php-cs-fixer: [Question] Enforce blank lines after closures and new lines before returns

Created on 11 Jul 2017  路  7Comments  路  Source: FriendsOfPHP/PHP-CS-Fixer

Hi guys,

Sorry that this is not an actual bug, but are there any pre-existing sniffs or configurations that allows for the following (or know how to add it in)

New line after closures e.g

array_filter($someArray, function () {
    return true;
});

$cake = 'yes please';

to prevent

array_filter($someArray, function () {
    return true;
});
$cake = 'yes please';

Force blank line before return statements (that are not the only statements in the method)

getSomething()
{
    $something = 'something';

    return $something;
}

or

getSomething()
{
    return 'something';
}

rather than

getSomething()
{
    $something = 'something';
    return $something;
}

Thanks :)

kinfeature request kinquestion

Most helpful comment

nah, who claimed we do? :P
that's why we have so many tests

All 7 comments

  1. no
  2. blank_line_before_return

Hi!

We've blank_line_before_return (on master there is blank_line_before_statement which will give even more options). We do not have a fixer for the last case (there is/was a WIP https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1853 for it).
For the first we could add a new option to blank_line_before_statement.

Let us know if you can help, all the suggestions you made seem like a nice extension to me :)

@SpacePossum , but what option would that be?
put a blank line above if there is a lambda param in previous statement ?
here, in example, it's just a tap method call...

Thanks for the heads up, I'll have a look around for info regarding the blank_line_before_return :)

I would love to help, however I've already nosed around the source code and to be honest, its insane ha, I've no idea how you guys know whats going on in there, way out of my depth!

nah, who claimed we do? :P
that's why we have so many tests

Hi.

I'd like to see blank_line_after_statement as well.

@gruz, sadly, it's impossible for us to implement all the requests. Maybe you could help on it and propose a PR ?

Was this page helpful?
0 / 5 - 0 ratings