@@ -1357,9 +1357,48 @@ function allowed()
1357
1357
}
1358
1358
```
1359
1359
1360
- ## 11. Attributes
1360
+ ## 11. Arrays
1361
1361
1362
- ### 11.1 Basics
1362
+ Arrays MUST be declared using the short array syntax.
1363
+
1364
+ ```php
1365
+ <?php
1366
+
1367
+ $arr = [];
1368
+ ```
1369
+
1370
+ Arrays MUST follow the trailing comma guidelines.
1371
+
1372
+ Array declarations MAY be split across multiple lines, where each subsequent line
1373
+ is indented once. When doing so, the first value in the array MUST be on the
1374
+ next line, and there MUST be only one value per line.
1375
+
1376
+ When the array declaration is split across multiple lines, the opening bracket
1377
+ MUST be placed on the same line as the equals sign. The closing bracket
1378
+ MUST be placed on the next line after the last value. There MUST NOT be more
1379
+ than one value assignment per line. Value assignments MAY use a single line
1380
+ or multiple lines.
1381
+
1382
+ ```php
1383
+ <?php
1384
+
1385
+ $arr1 = [ ' single' , ' line' , ' declaration' ];
1386
+
1387
+ $arr2 = [
1388
+ ' multi' ,
1389
+ ' line' ,
1390
+ ' declaration' ,
1391
+ [ ' values' => 1, 5, 7],
1392
+ [
1393
+ 'nested',
1394
+ 'array',
1395
+ ],
1396
+ ];
1397
+ ```
1398
+
1399
+ ## 12. Attributes
1400
+
1401
+ ### 12.1 Basics
1363
1402
1364
1403
Attribute names MUST immediately follow the opening attribute block indicator ` #[ ` with no space.
1365
1404
@@ -1370,7 +1409,7 @@ its argument list, with no preceding space.
1370
1409
1371
1410
The construct ` #[...] ` is referred to as an "attribute block" in this document.
1372
1411
1373
- ### 11 .2 Placement
1412
+ ### 12 .2 Placement
1374
1413
1375
1414
Attributes on classes, methods, functions, constants and properties MUST
1376
1415
be placed on their own line, immediately prior to the structure being described.
@@ -1389,7 +1428,7 @@ between the docblock and attributes, or the attributes and the structure.
1389
1428
If two separate attribute blocks are used in a multi-line context, they MUST be on separate lines with no blank
1390
1429
lines between them.
1391
1430
1392
- ### 11 .3 Compound attributes
1431
+ ### 12 .3 Compound attributes
1393
1432
1394
1433
If multiple attributes are placed in the same attribute block, they MUST be separated by a comma with a space
1395
1434
following but no space preceding. If the attribute list is split into multiple lines for any reason, then the
@@ -1401,7 +1440,7 @@ If an attribute's argument list is split into multiple lines for any reason, the
1401
1440
* The attribute MUST be the only one in its attribute block.
1402
1441
* The attribute arguments MUST follow the same rules as defined for multiline function calls.
1403
1442
1404
- ### 11 .4 Example
1443
+ ### 12 .4 Example
1405
1444
1406
1445
The following is an example of valid attribute usage.
1407
1446
0 commit comments