@@ -600,12 +600,16 @@ protected function pExpr_Variable(Expr\Variable $node): string {
600
600
}
601
601
602
602
protected function pExpr_Array (Expr \Array_ $ node ): string {
603
- $ syntax = $ node ->getAttribute ('kind ' ,
603
+ $ kind = $ node ->getAttribute ('kind ' ,
604
604
$ this ->shortArraySyntax ? Expr \Array_::KIND_SHORT : Expr \Array_::KIND_LONG );
605
+
606
+ $ forceMultiline = ($ kind & Expr \Array_::KIND_MULTILINE ) === Expr \Array_::KIND_MULTILINE ;
607
+ $ syntax = $ kind & ~Expr \Array_::KIND_MULTILINE ;
608
+
605
609
if ($ syntax === Expr \Array_::KIND_SHORT ) {
606
- return '[ ' . $ this ->pMaybeMultiline ($ node ->items , true ) . '] ' ;
610
+ return '[ ' . $ this ->pMaybeMultiline ($ node ->items , true , $ forceMultiline ) . '] ' ;
607
611
} else {
608
- return 'array( ' . $ this ->pMaybeMultiline ($ node ->items , true ) . ') ' ;
612
+ return 'array( ' . $ this ->pMaybeMultiline ($ node ->items , true , $ forceMultiline ) . ') ' ;
609
613
}
610
614
}
611
615
@@ -1181,12 +1185,12 @@ protected function hasNodeWithComments(array $nodes): bool {
1181
1185
}
1182
1186
1183
1187
/** @param Node[] $nodes */
1184
- protected function pMaybeMultiline (array $ nodes , bool $ trailingComma = false ): string {
1185
- if (!$ this ->hasNodeWithComments ($ nodes )) {
1186
- return $ this ->pCommaSeparated ($ nodes );
1187
- } else {
1188
+ protected function pMaybeMultiline (array $ nodes , bool $ trailingComma = false , bool $ forceMultiline = false ): string {
1189
+ if ($ forceMultiline || $ this ->hasNodeWithComments ($ nodes )) {
1188
1190
return $ this ->pCommaSeparatedMultiline ($ nodes , $ trailingComma ) . $ this ->nl ;
1189
1191
}
1192
+
1193
+ return $ this ->pCommaSeparated ($ nodes );
1190
1194
}
1191
1195
1192
1196
/** @param Node\Param[] $params
0 commit comments