martindilling
martindilling

Reputation: 2929

Avoid line breaks around anonymous functions when reformatting code

I'm working with PHP in IntelliJ 2017.3 (Same issue in PhpStorm). And I can't find an option in the Code Style to solve this issue I'm having.

When reformatting it makes a line break on both sides of the anonymous functions.

$collection
    ->map(
        function ($val) {
            return $val;
        }
    )
    ->each(
        function ($val) {
            return 'nope';
        }
    );

But I would like to keep the function declaration and closing brace inline.

$collection
    ->map(function ($val) {
        return $val;
    })
    ->each(function ($val) {
        return 'nope';
    });

Is there some setting I'm missing? :)

Upvotes: 1

Views: 239

Answers (1)

Jeto
Jeto

Reputation: 14927

Go to:

Settings > Editor > Code Style > PHP > Wrapping and Braces > Function/constructor call arguments > New line after '('

Uncheck if checked, should be better.

Upvotes: 3

Related Questions