Skip to content

Commit f437b8b

Browse files
authored
docs: add error message wording conventions to CODING_STANDARDS (php#21761)
1 parent be67a37 commit f437b8b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CODING_STANDARDS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ rewritten to comply with these rules.
7979
return value for functions that perform some operation that may
8080
succeed or fail.
8181

82+
1. When throwing a `ValueError` or emitting a warning, use consistent
83+
phrasing for error messages. Common patterns are:
84+
85+
* Type errors: `must be of type int` (use the type name, not e.g. `must be an integer`)
86+
* Range/boundary: `must be between X and Y` / `must be greater than [or equal to] X` / `must be less than X` / `must be finite`
87+
* String constraints: `must not contain any null bytes` / `must not be empty` / `must be a single character`
88+
* Valid value: `must be a valid X` (e.g. `must be a valid encoding`, `must be a valid calendar ID`)
89+
* Enum-like: `must be one of X, Y, or Z`
90+
* Structural: `must have X` / `must have key X` / `must have N elements`
91+
8292
## User functions/methods naming conventions
8393

8494
1. Function names for user-level functions should be enclosed with in the

0 commit comments

Comments
 (0)