I am currently trying to use the PEAR Coding Standards and I can't get anonymous functions to align correctly in function calls. Here is an example :
What is recommended by the standards:
test(
function () {
return "";
}
);
This works by default.
However, as soon as I have more than one parameter, PhpStorm unindents the function content and closing brace :
test(
"test", function () {
return "";
}
);
But what is recommended by the standards is the following :
test(
"test", function () {
return "";
}
);
Note: When enabling "Function declaration parameters" > "Align when multiline", I have the correct alignment if I put each parameter on its own line :
test(
"test",
function () {
return "";
}
);
I couldn't find a way to make this possible without having to put each parameter on its own line, would someone if this is possible/how to do it ?
Note 2 : I loaded the PEAR Coding Style using the "Predefined Style" already implemented out of the box in PhpStorm and only did little tweaks.
Note 3 : I am using PHPCS to check my code. Here are the errors I get with the PhpStorm-formatted code :
4 | ERROR | [x] Line indented incorrectly; expected at least 8 spaces, found 4 (PEAR.WhiteSpace.ScopeIndent.Incorrect)
5 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0 (PEAR.WhiteSpace.ScopeIndent.IncorrectExact)
5 | ERROR | [x] Multi-line function call not indented correctly; expected 4 spaces but found 0 | | (PEAR.Functions.FunctionCallSignature.Indent)
5 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces, found 0 (PEAR.WhiteSpace.ScopeClosingBrace.Indent)
Line 4 is the line where the return ""; is.
functionkeyword.) I updated the post to include the errors I get from PHPCS.