File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1047,6 +1047,36 @@ $foo->bar(
10471047);
10481048```
10491049
1050+ ### 7.1 Short Closures
1051+
1052+ Short closures, also known as arrow functions, MUST follow the same guidelines
1053+ and principles as long closures above, with the following additions.
1054+
1055+ The ` fn ` keyword MUST be preceded and succeeded by a space.
1056+
1057+ The ` => ` symbol MUST be preceded and succeeded by a space.
1058+
1059+ The semicolon at the end of the expression MUST NOT be preceded by a space.
1060+
1061+ The expression portion MAY be split to a subsequent line. If so, the ` => ` MUST be included
1062+ on the second line, and MUST be indented once.
1063+
1064+ The following examples show proper common usage of short closures.
1065+
1066+ ``` php
1067+
1068+ $func = fn (int $x, int $y): int => $x + $y;
1069+
1070+ $func = fn (int $x, int $y): int
1071+ => $x + $y;
1072+
1073+ $func = fn (
1074+ int $x,
1075+ int $y
1076+ ): int
1077+ => $x + $y;
1078+ ```
1079+
10501080## 8. Anonymous Classes
10511081
10521082Anonymous Classes MUST follow the same guidelines and principles as closures
You can’t perform that action at this time.
0 commit comments