Awesome.
My thought was something super simple like
"How many blank lines follow a solo curly brace "{"
So then it doesn't have to be aware or smart or anything, it just adds an option for NO blank lines after a curly brace on a line by itself... And that would TRUMP all the others, so all the other rules would apply as they are now, "method" / function, class etc... but they'd only apply themselves after they've checked if the curly brace "is alone on line" rule first...
So like "0, 1, ignore" would be the options.
But I totally understand how that could be something that would just melt the entire goodness of things down! 😄
So I could keep my options set with "blank lines before method body" set to 1, but that rule would just only apply itself if the "curly brace on line alone" rule wasn't set.
(And to further over explain this simple concept which I am sure you already understood! hahaha.)
That way functions and methods like
public function myFunction($myParam): array {
$myVar = $myParam;
}
would stay like this also. Versus becoming
public function myFunction($myParam): array {
$myVar = $myParam;
}
And
public function myFunction($myParam): array
{
$myVar = $myParam;
}
Would stay like this instead of becoming
public function myFunction($myParam): array
{
$myVar = $myParam;
}
But something like
public function myFunction(
int $param1,
array $param2,
Collection $param3,
array $param4
): int {
$myVar1 = $param1;
$myVar2 = $param2['index1'];
$myVar3 = $param3->prop1;
$myVar4 = $param4['index1'];
return $myVar1 + $myVar2 + $myVar3 + $myVar4;
}
Would indeed catch the method body rule since the { is not on the line by itself and become
public function myFunction(
int $param1,
array $param2,
Collection $param3,
array $param4
): int {
$myVar1 = $param1;
$myVar2 = $param2['index1'];
$myVar3 = $param3->prop1;
$myVar4 = $param4['index1'];
return $myVar1 + $myVar2 + $myVar3 + $myVar4;
}