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 @@ -1076,6 +1076,36 @@ $instance = new class extends \Foo implements
1076
1076
};
1077
1077
~~~
1078
1078
1079
+ ## 9. Enumerations
1080
+
1081
+ Enumerations MUST follow the same guidelines as classes, except where otherwise noted here.
1082
+
1083
+ Methods in Enumerations MUST follow the same guidelines as methods in classes. Non-public methods MUST use ` private `
1084
+ instead of ` protected ` .
1085
+
1086
+ In the case of a backed enum, there MUST NOT be a space between the enum name and colon, and there MUST be exactly one
1087
+ space between the colon and the backing type.
1088
+
1089
+ Enumeration cases MUST use CamelCase capitalization.
1090
+
1091
+ Constants in Enumerations MAY use either CamelCase or UPPER_CASE capitalization. CamelCase is RECOMMENDED,
1092
+ so that it is consistent with cases.
1093
+
1094
+ No more than one case is permitted per line.
1095
+
1096
+ ``` php
1097
+ enum Suit: string
1098
+ {
1099
+ case Hearts = 'H';
1100
+ case Diamonds = 'D';
1101
+ case Spades = 'S';
1102
+ case Clubs = 'C';
1103
+
1104
+ const Wild = self::Spades;
1105
+ }
1106
+
1107
+ ```
1108
+
1079
1109
[ PSR-1 ] : https://www.php-fig.org/psr/psr-1/
1080
1110
[ PSR-2 ] : https://www.php-fig.org/psr/psr-2/
1081
1111
[ keywords ] : http://php.net/manual/en/reserved.keywords.php
You can’t perform that action at this time.
0 commit comments