@@ -48,7 +48,7 @@ public function printFunction(GlobalFunction $function, ?PhpNamespace $namespace
4848 $ params = $ this ->printParameters ($ function , strlen ($ line ) + strlen ($ returnType ) + 2 ); // 2 = parentheses
4949 $ body = Helpers::simplifyTaggedNames ($ function ->getBody (), $ this ->namespace );
5050 $ body = ltrim (rtrim (Strings::normalize ($ body )) . "\n" );
51- $ braceOnNextLine = $ this ->bracesOnNextLine && (! str_contains ($ params , "\n" ) || $ returnType );
51+ $ braceOnNextLine = $ this ->isBraceOnNextLine ( str_contains ($ params , "\n" ), ( bool ) $ returnType );
5252
5353 return $ this ->printDocComment ($ function )
5454 . $ this ->printAttributes ($ function ->getAttributes ())
@@ -119,7 +119,7 @@ public function printMethod(Method $method, ?PhpNamespace $namespace = null, boo
119119 $ params = $ this ->printParameters ($ method , strlen ($ line ) + strlen ($ returnType ) + strlen ($ this ->indentation ) + 2 );
120120 $ body = Helpers::simplifyTaggedNames ($ method ->getBody (), $ this ->namespace );
121121 $ body = ltrim (rtrim (Strings::normalize ($ body )) . "\n" );
122- $ braceOnNextLine = $ this ->bracesOnNextLine && (! str_contains ($ params , "\n" ) || $ returnType );
122+ $ braceOnNextLine = $ this ->isBraceOnNextLine ( str_contains ($ params , "\n" ), ( bool ) $ returnType );
123123
124124 return $ this ->printDocComment ($ method )
125125 . $ this ->printAttributes ($ method ->getAttributes ())
@@ -466,4 +466,10 @@ private function joinProperties(array $props): string
466466 ? implode (str_repeat ("\n" , $ this ->linesBetweenProperties ), $ props )
467467 : preg_replace ('#^(\w.*\n)\n(?=\w.*;)#m ' , '$1 ' , implode ("\n" , $ props ));
468468 }
469+
470+
471+ protected function isBraceOnNextLine (bool $ multiLine , bool $ hasReturnType ): bool
472+ {
473+ return $ this ->bracesOnNextLine && (!$ multiLine || $ hasReturnType );
474+ }
469475}
0 commit comments