From 6308981645bbe8b512929a3288a9278669b07c29 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 22 Jun 2026 13:30:47 +0000 Subject: [PATCH] Section 9: Apply the private instead of protected rule to enum constants Section 9 required non-public enum methods to use `private` instead of `protected` but said nothing about constants. The rationale that enums do not support inheritance so `protected` is meaningless applies equally to constants, so the omission was likely an oversight (see issue 150). While broadening the rule, I also dropped the "Methods in enums MUST follow the same guidelines as methods in classes" sentence. I first considered just adding constants to it, but that sentence was already redundant with the opening line, which states that enums follow the guidelines for classes. Spelling out "methods and constants" would only have made the duplication more obvious. So instead I collapsed it into the opening line, which now mentions class methods and constants explicitly to preserve that emphasis. --- spec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.md b/spec.md index ede3ef0..d23703c 100644 --- a/spec.md +++ b/spec.md @@ -1597,10 +1597,10 @@ $example = new ## 9. Enumerations -Enumerations (enums) MUST follow the same guidelines as classes, except where otherwise noted below. +Enumerations (enums) MUST follow the same guidelines as classes (including the guidelines for class methods and +constants), except where otherwise noted below. -Methods in enums MUST follow the same guidelines as methods in classes. Non-public methods MUST use `private` -instead of `protected`, as enums do not support inheritance. +Non-public methods and constants MUST use `private` instead of `protected`, as enums do not support inheritance. When using a backed enum, there MUST NOT be a space between the enum name and colon, and there MUST be exactly one space between the colon and the backing type. This is consistent with the style for return types.