Skip to content

Commit 4adebbc

Browse files
committed
Assorted fixups.
1 parent 047ba01 commit 4adebbc

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

spec.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -232,7 +243,7 @@ declare(ticks=1) {
232243

233244
## 4. Classes, Properties, and Methods
234245

235-
The term "class" refers to all classes, interfaces, and traits.
246+
The term "class" refers to all classes, interfaces, traits, and enums.
236247

237248
Any closing brace MUST NOT be followed by any comment or statement on the
238249
same line.
@@ -1078,21 +1089,19 @@ $instance = new class extends \Foo implements
10781089

10791090
## 9. Enumerations
10801091

1081-
Enumerations MUST follow the same guidelines as classes, except where otherwise noted here.
1092+
Enumerations (enums) MUST follow the same guidelines as classes, except where otherwise noted here.
10821093

1083-
Methods in Enumerations MUST follow the same guidelines as methods in classes. Non-public methods MUST use `private`
1084-
instead of `protected`.
1094+
Methods in enums MUST follow the same guidelines as methods in classes. Non-public methods MUST use `private`
1095+
instead of `protected`, as enums do not support inheritance.
10851096

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.
1097+
When using a backed enum, there MUST NOT be a space between the enum name and colon, and there MUST be exactly one
1098+
space between the colon and the backing type. This is consistent with the style for return types.
10881099

1089-
Enumeration cases MUST use CamelCase capitalization.
1100+
Enum case declarations MUST use CamelCase capitalization. Enum case declarations MUST be on their own line.
10901101

10911102
Constants in Enumerations MAY use either CamelCase or UPPER_CASE capitalization. CamelCase is RECOMMENDED,
10921103
so that it is consistent with cases.
10931104

1094-
No more than one case is permitted per line.
1095-
10961105
```php
10971106
enum Suit: string
10981107
{

0 commit comments

Comments
 (0)