@@ -592,12 +592,16 @@ protected function pExpr_Variable(Expr\Variable $node): string {
592
592
}
593
593
594
594
protected function pExpr_Array (Expr \Array_ $ node ): string {
595
- $ syntax = $ node ->getAttribute ('kind ' ,
595
+ $ kind = $ node ->getAttribute ('kind ' ,
596
596
$ this ->shortArraySyntax ? Expr \Array_::KIND_SHORT : Expr \Array_::KIND_LONG );
597
+
598
+ $ forceMultiline = ($ kind & Expr \Array_::KIND_MULTILINE ) === Expr \Array_::KIND_MULTILINE ;
599
+ $ syntax = $ kind & ~Expr \Array_::KIND_MULTILINE ;
600
+
597
601
if ($ syntax === Expr \Array_::KIND_SHORT ) {
598
- return '[ ' . $ this ->pMaybeMultiline ($ node ->items , true ) . '] ' ;
602
+ return '[ ' . $ this ->pMaybeMultiline ($ node ->items , true , $ forceMultiline ) . '] ' ;
599
603
} else {
600
- return 'array( ' . $ this ->pMaybeMultiline ($ node ->items , true ) . ') ' ;
604
+ return 'array( ' . $ this ->pMaybeMultiline ($ node ->items , true , $ forceMultiline ) . ') ' ;
601
605
}
602
606
}
603
607
@@ -1171,12 +1175,12 @@ protected function hasNodeWithComments(array $nodes): bool {
1171
1175
}
1172
1176
1173
1177
/** @param Node[] $nodes */
1174
- protected function pMaybeMultiline (array $ nodes , bool $ trailingComma = false ): string {
1175
- if (!$ this ->hasNodeWithComments ($ nodes )) {
1176
- return $ this ->pCommaSeparated ($ nodes );
1177
- } else {
1178
+ protected function pMaybeMultiline (array $ nodes , bool $ trailingComma = false , bool $ forceMultiline = false ): string {
1179
+ if ($ forceMultiline || $ this ->hasNodeWithComments ($ nodes )) {
1178
1180
return $ this ->pCommaSeparatedMultiline ($ nodes , $ trailingComma ) . $ this ->nl ;
1179
1181
}
1182
+
1183
+ return $ this ->pCommaSeparated ($ nodes );
1180
1184
}
1181
1185
1182
1186
/** @param Node\AttributeGroup[] $nodes */
0 commit comments