@@ -45,15 +45,17 @@ public function printFunction(GlobalFunction $function, ?PhpNamespace $namespace
45
45
. ($ function ->getReturnReference () ? '& ' : '' )
46
46
. $ function ->getName ();
47
47
$ returnType = $ this ->printReturnType ($ function );
48
+ $ params = $ this ->printParameters ($ function , strlen ($ line ) + strlen ($ returnType ) + 2 ); // 2 = parentheses
48
49
$ body = Helpers::simplifyTaggedNames ($ function ->getBody (), $ this ->namespace );
49
50
$ body = ltrim (rtrim (Strings::normalize ($ body )) . "\n" );
51
+ $ braceOnNextLine = $ this ->bracesOnNextLine && (!str_contains ($ params , "\n" ) || $ returnType );
50
52
51
53
return $ this ->printDocComment ($ function )
52
54
. $ this ->printAttributes ($ function ->getAttributes ())
53
55
. $ line
54
- . $ this -> printParameters ( $ function , strlen ( $ line ) + strlen ( $ returnType ) + 2 ) // 2 = parentheses
56
+ . $ params
55
57
. $ returnType
56
- . ($ this -> bracesOnNextLine ? "\n" : ' ' )
58
+ . ($ braceOnNextLine ? "\n" : ' ' )
57
59
. "{ \n" . $ this ->indent ($ body ) . "} \n" ;
58
60
}
59
61
@@ -117,7 +119,7 @@ public function printMethod(Method $method, ?PhpNamespace $namespace = null, boo
117
119
$ params = $ this ->printParameters ($ method , strlen ($ line ) + strlen ($ returnType ) + strlen ($ this ->indentation ) + 2 );
118
120
$ body = Helpers::simplifyTaggedNames ($ method ->getBody (), $ this ->namespace );
119
121
$ body = ltrim (rtrim (Strings::normalize ($ body )) . "\n" );
120
- $ braceOnNextLine = $ this ->bracesOnNextLine && !str_contains ($ params , "\n" );
122
+ $ braceOnNextLine = $ this ->bracesOnNextLine && ( !str_contains ($ params , "\n" ) || $ returnType );
121
123
122
124
return $ this ->printDocComment ($ method )
123
125
. $ this ->printAttributes ($ method ->getAttributes ())
0 commit comments