@@ -131,7 +131,7 @@ Short form of type keywords MUST be used i.e. `bool` instead of `boolean`,
131
131
### 2.6 Trailing commas
132
132
133
133
Numerous PHP constructs allow a sequence of values to be separated by a comma,
134
- and the final item may have an optional comma. Examples include array key/value pairs,
134
+ and the final item may have an optional comma. Examples include array key/value pairs,
135
135
function arguments, closure ` use ` statements, ` match() ` statement branches, etc.
136
136
137
137
If that list is contained on a single line, then the last item MUST NOT have a trailing comma.
@@ -294,15 +294,15 @@ Any closing brace MUST NOT be followed by any comment or statement on the
294
294
same line.
295
295
296
296
When instantiating a new class, parentheses MUST always be present even when
297
- there are no arguments passed to the constructor. For example:
297
+ there are no arguments passed to the constructor. For example:
298
298
299
299
``` php
300
300
new Foo();
301
301
```
302
302
303
303
If class contains no additional declarations (such as an exception that exists only extend another exception with a new type),
304
304
then the body of the class SHOULD be abbreviated as ` {} ` and placed on the same line as the previous symbol,
305
- separated by a space. For example:
305
+ separated by a space. For example:
306
306
307
307
``` php
308
308
class MyException extends \RuntimeException {}
@@ -339,7 +339,7 @@ class ClassName extends ParentClass implements \ArrayAccess, \Countable
339
339
Lists of ` implements ` and, in the case of interfaces, ` extends ` MAY be split
340
340
across multiple lines, where each subsequent line is indented once. When doing
341
341
so, the first item in the list MUST be on the next line, and there MUST be only
342
- one interface per line. For example:
342
+ one interface per line. For example:
343
343
344
344
``` php
345
345
<?php
@@ -514,7 +514,7 @@ function fooBarBaz($arg1, &$arg2, $arg3 = [])
514
514
515
515
If a function or method contains no statements (such as a no-op implementation or when using
516
516
constructor property promotion), then the body SHOULD be abbreviated as ` {} ` and placed on the same
517
- line as the previous symbol, separated by a space. For example:
517
+ line as the previous symbol, separated by a space. For example:
518
518
519
519
``` php
520
520
class Point
@@ -541,7 +541,7 @@ In the argument list, there MUST NOT be a space before each comma, and there
541
541
MUST be one space after each comma.
542
542
543
543
Method and function parameters with default values MUST go at the end of the argument
544
- list. For example:
544
+ list. For example:
545
545
546
546
``` php
547
547
<?php
@@ -563,7 +563,7 @@ next line, and there MUST be only one argument per line.
563
563
564
564
When the argument list is split across multiple lines, the closing parenthesis
565
565
and opening brace MUST be placed together on their own line with one space
566
- between them. For example:
566
+ between them. For example:
567
567
568
568
``` php
569
569
<?php
@@ -585,7 +585,7 @@ class ClassName
585
585
When you have a return type declaration present, there MUST be one space after
586
586
the colon followed by the type declaration. The colon and declaration MUST be
587
587
on the same line as the argument list closing parenthesis with no spaces between
588
- the two characters. For example:
588
+ the two characters. For example:
589
589
590
590
``` php
591
591
<?php
@@ -612,7 +612,7 @@ class ReturnTypeVariations
612
612
```
613
613
614
614
In nullable type declarations, there MUST NOT be a space between the question mark
615
- and the type. For example:
615
+ and the type. For example:
616
616
617
617
``` php
618
618
<?php
@@ -656,7 +656,7 @@ public function process(string $algorithm, &...$parts)
656
656
### 4.6 Modifier Keywords
657
657
658
658
Classes, properties, and methods have numerous keyword modifiers that alter how the
659
- engine and language handles them. When present, they MUST be in the following order:
659
+ engine and language handles them. When present, they MUST be in the following order:
660
660
661
661
* Inheritance modifier: ` abstract ` or ` final `
662
662
* Visibility modifier: ` public ` , ` protected ` , or ` private `
@@ -743,14 +743,14 @@ $app->get('/hello/{name}', function ($name) use ($app) {
743
743
```
744
744
745
745
If using named arguments, there MUST NOT be a space between the argument name
746
- and colon, and there MUST be a single space between the colon and the argument value. For example:
746
+ and colon, and there MUST be a single space between the colon and the argument value. For example:
747
747
748
748
``` php
749
749
somefunction($a, b: $b, c: 'c');
750
750
```
751
751
752
752
Method chaining MAY be put on separate lines, where each subsequent line is indented once. When doing so, the first
753
- method MUST be on the next line. For example:
753
+ method MUST be on the next line. For example:
754
754
755
755
``` php
756
756
$someInstance
@@ -763,7 +763,7 @@ $someInstance
763
763
764
764
A function or method may be referenced in a way that creates a closure out of it, by providing ` ... ` in place of arguments.
765
765
766
- If so, the ` ... ` MUST NOT include any whitespace before or after. That is, the correct format is ` foo(...) ` .
766
+ If so, the ` ... ` MUST NOT include any whitespace before or after. That is, the correct format is ` foo(...) ` .
767
767
768
768
## 5. Control Structures
769
769
@@ -964,8 +964,7 @@ for ($i = 0; $i < 10; $i++) {
964
964
Expressions in parentheses MAY be split across multiple lines, where each
965
965
subsequent line is indented at least once. When doing so, the first expression
966
966
MUST be on the next line. The closing parenthesis and opening brace MUST be
967
- placed together on their own line with one space between them. The semicolons
968
- MUST be on the component they follow, not on the subsequent line. For example:
967
+ placed together on their own line with one space between them. For example:
969
968
970
969
``` php
971
970
<?php
@@ -1195,7 +1194,7 @@ The `=>` symbol MUST be preceded and succeeded by a space.
1195
1194
1196
1195
The semicolon at the end of the expression MUST NOT be preceded by a space.
1197
1196
1198
- The expression portion MAY be split to a subsequent line. If so, the ` => ` MUST be included
1197
+ The expression portion MAY be split to a subsequent line. If so, the ` => ` MUST be included
1199
1198
on the second line, and MUST be indented once.
1200
1199
1201
1200
The following examples show proper common usage of short closures.
@@ -1261,13 +1260,13 @@ $instance = new class($a) extends \Foo implements
1261
1260
1262
1261
Enumerations (enums) MUST follow the same guidelines as classes, except where otherwise noted below.
1263
1262
1264
- Methods in enums MUST follow the same guidelines as methods in classes. Non-public methods MUST use ` private `
1263
+ Methods in enums MUST follow the same guidelines as methods in classes. Non-public methods MUST use ` private `
1265
1264
instead of ` protected ` , as enums do not support inheritance.
1266
1265
1267
1266
When using a backed enum, there MUST NOT be a space between the enum name and colon, and there MUST be exactly one
1268
- space between the colon and the backing type. This is consistent with the style for return types.
1267
+ space between the colon and the backing type. This is consistent with the style for return types.
1269
1268
1270
- Enum case declarations MUST use PascalCase capitalization. Enum case declarations MUST be on their own line.
1269
+ Enum case declarations MUST use PascalCase capitalization. Enum case declarations MUST be on their own line.
1271
1270
1272
1271
Constants in Enumerations MAY use either PascalCase or UPPER_CASE capitalization. PascalCase is RECOMMENDED,
1273
1272
so that it is consistent with case declarations.
@@ -1429,12 +1428,12 @@ be placed on their own line, immediately prior to the structure being described.
1429
1428
For attributes on parameters, if the parameter list is presented on a single line,
1430
1429
the attribute MUST be placed inline with the parameter it describes, separated by a single space.
1431
1430
If the parameter list is split into multiple lines for any reason, the attribute MUST be placed on
1432
- its own line prior to the parameter, indented the same as the parameter. If the parameter list
1431
+ its own line prior to the parameter, indented the same as the parameter. If the parameter list
1433
1432
is split into multiple lines, a blank line MAY be included between one parameter and the attributes
1434
1433
of the following parameter in order to aid readability.
1435
1434
1436
1435
If a comment docblock is present on a structure that also includes an attribute, the comment block MUST
1437
- come first, followed by any attributes, followed by the structure itself. There MUST NOT be any blank lines
1436
+ come first, followed by any attributes, followed by the structure itself. There MUST NOT be any blank lines
1438
1437
between the docblock and attributes, or the attributes and the structure.
1439
1438
1440
1439
If two separate attribute blocks are used in a multi-line context, they MUST be on separate lines with no blank
@@ -1443,7 +1442,7 @@ lines between them.
1443
1442
### 12.3 Compound attributes
1444
1443
1445
1444
If multiple attributes are placed in the same attribute block, they MUST be separated by a comma with a space
1446
- following but no space preceding. If the attribute list is split into multiple lines for any reason, then the
1445
+ following but no space preceding. If the attribute list is split into multiple lines for any reason, then the
1447
1446
attributes MUST be placed in separate attribute blocks. Those blocks may themselves contain multiple
1448
1447
attributes provided this rule is respected.
1449
1448
0 commit comments