@@ -68,6 +68,17 @@ class Foo extends Bar implements FooInterface
6868 // method body
6969 }
7070}
71+
72+ Enum Beep: int
73+ {
74+ case A = 1;
75+ case B = 2;
76+
77+ public function isOdd(): bool
78+ {
79+ return $this->value() % 2;
80+ }
81+ }
7182```
7283
7384## 2. General
@@ -233,7 +244,7 @@ declare(ticks=1) {
233244
234245## 4. Classes, Properties, and Methods
235246
236- The term "class" refers to all classes, interfaces, and traits .
247+ The term "class" refers to all classes, interfaces, traits, and enums .
237248
238249Any closing brace MUST NOT be followed by any comment or statement on the
239250same line.
@@ -1083,21 +1094,19 @@ $instance = new class extends \Foo implements
10831094
10841095## 9. Enumerations
10851096
1086- Enumerations MUST follow the same guidelines as classes, except where otherwise noted here.
1097+ Enumerations (enums) MUST follow the same guidelines as classes, except where otherwise noted here.
10871098
1088- Methods in Enumerations MUST follow the same guidelines as methods in classes. Non-public methods MUST use ` private `
1089- instead of ` protected ` .
1099+ Methods in enums MUST follow the same guidelines as methods in classes. Non-public methods MUST use ` private `
1100+ instead of ` protected ` , as enums do not support inheritance .
10901101
1091- 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
1092- space between the colon and the backing type.
1102+ When using a backed enum, there MUST NOT be a space between the enum name and colon, and there MUST be exactly one
1103+ space between the colon and the backing type. This is consistent with the style for return types.
10931104
1094- Enumeration cases MUST use CamelCase capitalization.
1105+ Enum case declarations MUST use CamelCase capitalization. Enum case declarations MUST be on their own line .
10951106
10961107Constants in Enumerations MAY use either CamelCase or UPPER_CASE capitalization. CamelCase is RECOMMENDED,
10971108so that it is consistent with cases.
10981109
1099- No more than one case is permitted per line.
1100-
11011110``` php
11021111enum Suit: string
11031112{
0 commit comments