@@ -45,15 +45,17 @@ public function printFunction(GlobalFunction $function, ?PhpNamespace $namespace
4545 . ($ function ->getReturnReference () ? '& ' : '' )
4646 . $ function ->getName ();
4747 $ returnType = $ this ->printReturnType ($ function );
48+ $ params = $ this ->printParameters ($ function , strlen ($ line ) + strlen ($ returnType ) + 2 ); // 2 = parentheses
4849 $ body = Helpers::simplifyTaggedNames ($ function ->getBody (), $ this ->namespace );
4950 $ body = ltrim (rtrim (Strings::normalize ($ body )) . "\n" );
51+ $ braceOnNextLine = $ this ->bracesOnNextLine && (!str_contains ($ params , "\n" ) || $ returnType );
5052
5153 return $ this ->printDocComment ($ function )
5254 . $ this ->printAttributes ($ function ->getAttributes ())
5355 . $ line
54- . $ this -> printParameters ( $ function , strlen ( $ line ) + strlen ( $ returnType ) + 2 ) // 2 = parentheses
56+ . $ params
5557 . $ returnType
56- . ($ this -> bracesOnNextLine ? "\n" : ' ' )
58+ . ($ braceOnNextLine ? "\n" : ' ' )
5759 . "{ \n" . $ this ->indent ($ body ) . "} \n" ;
5860 }
5961
@@ -117,7 +119,7 @@ public function printMethod(Method $method, ?PhpNamespace $namespace = null, boo
117119 $ params = $ this ->printParameters ($ method , strlen ($ line ) + strlen ($ returnType ) + strlen ($ this ->indentation ) + 2 );
118120 $ body = Helpers::simplifyTaggedNames ($ method ->getBody (), $ this ->namespace );
119121 $ body = ltrim (rtrim (Strings::normalize ($ body )) . "\n" );
120- $ braceOnNextLine = $ this ->bracesOnNextLine && !str_contains ($ params , "\n" );
122+ $ braceOnNextLine = $ this ->bracesOnNextLine && ( !str_contains ($ params , "\n" ) || $ returnType );
121123
122124 return $ this ->printDocComment ($ method )
123125 . $ this ->printAttributes ($ method ->getAttributes ())
0 commit comments