@@ -48,7 +48,7 @@ public function printFunction(GlobalFunction $function, ?PhpNamespace $namespace
48
48
$ params = $ this ->printParameters ($ function , strlen ($ line ) + strlen ($ returnType ) + 2 ); // 2 = parentheses
49
49
$ body = Helpers::simplifyTaggedNames ($ function ->getBody (), $ this ->namespace );
50
50
$ 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 );
52
52
53
53
return $ this ->printDocComment ($ function )
54
54
. $ this ->printAttributes ($ function ->getAttributes ())
@@ -119,7 +119,7 @@ public function printMethod(Method $method, ?PhpNamespace $namespace = null, boo
119
119
$ params = $ this ->printParameters ($ method , strlen ($ line ) + strlen ($ returnType ) + strlen ($ this ->indentation ) + 2 );
120
120
$ body = Helpers::simplifyTaggedNames ($ method ->getBody (), $ this ->namespace );
121
121
$ 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 );
123
123
124
124
return $ this ->printDocComment ($ method )
125
125
. $ this ->printAttributes ($ method ->getAttributes ())
@@ -466,4 +466,10 @@ private function joinProperties(array $props): string
466
466
? implode (str_repeat ("\n" , $ this ->linesBetweenProperties ), $ props )
467
467
: preg_replace ('#^(\w.*\n)\n(?=\w.*;)#m ' , '$1 ' , implode ("\n" , $ props ));
468
468
}
469
+
470
+
471
+ protected function isBraceOnNextLine (bool $ multiLine , bool $ hasReturnType ): bool
472
+ {
473
+ return $ this ->bracesOnNextLine && (!$ multiLine || $ hasReturnType );
474
+ }
469
475
}
0 commit comments