Search code examples
phpstormcode-formatting

How to fix function declaration formatting in PhpStorm (2020.1.2) if signature longer then defined row length?


For example I have function declaration like this:

public function someLongMethodWithLongParamName(int $longparamName): VeryLongReturnValueType {}

with row length limit that less than chars count of function signature.

If I type Ctrl + Alt + L PhpStorm will format this row, but in strange way:

public function someLongMethodWithLongParamName(int $longparamName
): VeryLongReturnValueType {
}

(PhpStorm left parameter in the line of method name). If I will add one more parameter, PhpStorm will format line correct:

public function someLongMethodWithLongParamName(
    int $longparamName,
    bool $flag
): VeryLongReturnValueType {
}

Maybe someone deal with such bug?

P.S. Here are my Code Style settings:

code style


Solution

  • Looks like you want it to wrap parameter & its type also? Then remove the Place ')' on new line checkbox in Method declaration parameters settings from your screenshot.