File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
test/code/prettyPrinter/stmt Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -1267,13 +1267,19 @@ class_constant:
1267
1267
1268
1268
array_short_syntax:
1269
1269
' [' array_pair_list ' ]'
1270
- { $attrs = attributes (); $attrs[' kind' ] = Expr\Array_::KIND_SHORT;
1270
+ { $attrs = attributes ();
1271
+ $attrs[' kind' ] = $this ->isMultiline ($attrs)
1272
+ ? Expr\Array_::KIND_SHORT | Expr\Array_::KIND_MULTILINE
1273
+ : Expr\Array_::KIND_SHORT;
1271
1274
$$ = new Expr\Array_ ($2 , $attrs); }
1272
1275
;
1273
1276
1274
1277
dereferenceable_scalar:
1275
1278
T_ARRAY ' (' array_pair_list ' )'
1276
- { $attrs = attributes (); $attrs[' kind' ] = Expr\Array_::KIND_LONG;
1279
+ { $attrs = attributes ();
1280
+ $attrs[' kind' ] = $this ->isMultiline ($attrs)
1281
+ ? Expr\Array_::KIND_LONG | Expr\Array_::KIND_MULTILINE
1282
+ : Expr\Array_::KIND_LONG;
1277
1283
$$ = new Expr\Array_ ($3 , $attrs);
1278
1284
$this ->createdArrays ->offsetSet ($$); }
1279
1285
| array_short_syntax
Original file line number Diff line number Diff line change @@ -1264,6 +1264,14 @@ private function isSimpleExit(array $args): bool {
1264
1264
return false ;
1265
1265
}
1266
1266
1267
+ protected function isMultiline (array $ attributes ): bool {
1268
+ if (!isset ($ attributes ['startLine ' ]) || !isset ($ attributes ['endLine ' ])) {
1269
+ return false ;
1270
+ }
1271
+
1272
+ return $ attributes ['startLine ' ] !== $ attributes ['endLine ' ];
1273
+ }
1274
+
1267
1275
/**
1268
1276
* @param array<Node\Arg|Node\VariadicPlaceholder> $args
1269
1277
* @param array<string, mixed> $attrs
Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ $longMultiline = array(
17
17
);
18
18
-----
19
19
$short = [1, 2, 3];
20
- $shortMultiline = [1, 2, 3];
20
+ $shortMultiline = [
21
+ 1,
22
+ 2,
23
+ 3,
24
+ ];
21
25
$long = array(1, 2, 3);
22
- $longMultiline = array(1, 2, 3);
26
+ $longMultiline = array(
27
+ 1,
28
+ 2,
29
+ 3,
30
+ );
You can’t perform that action at this time.
0 commit comments