Skip to content
Advertisement

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? 🙂

Advertisement

Answer

Go to:

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

Uncheck if checked, should be better.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement