Skip to content

Commit 48971af

Browse files
TimWollaCrell
andauthored
Update CODING_STANDARDS for the acronym casing RFC (#14169)
* [skip ci] Update CODING_STANDARDS for the acronym casing RFC see https://wiki.php.net/rfc/class-naming-acronyms * Improve formatting in CODING_STANDARDS.md Co-authored-by: Larry Garfield <larry@garfieldtech.com> --------- Co-authored-by: Larry Garfield <larry@garfieldtech.com>
1 parent 70b5a4d commit 48971af

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

CODING_STANDARDS.md

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,62 +152,74 @@ rewritten to comply with these rules.
152152
1. Method names follow the *studlyCaps* (also referred to as *bumpy case* or
153153
*camel caps*) naming convention, with care taken to minimize the letter
154154
count. The initial letter of the name is lowercase, and each letter that
155-
starts a new `word` is capitalized:
155+
starts a new "word" is capitalized.
156156

157-
Good:
157+
1. Class names should be descriptive nouns in *PascalCase* and as short as
158+
possible. Each word in the class name should start with a capital letter,
159+
without underscore delimiters. The class name should be prefixed with the
160+
name of the "parent set" (e.g. the name of the extension) if no namespaces
161+
are used.
162+
163+
1. Abbreviations and acronyms as well as initialisms should be avoided wherever
164+
possible, unless they are much more widely used than the long form (e.g. HTTP
165+
or URL). Abbreviations, acronyms, and initialisms should be treated like
166+
regular words, thus they should be written with an uppercase first character,
167+
followed by lowercase characters.
168+
169+
1. Diverging from this policy is allowed to keep internal consistency within a
170+
single extension, if the name follows an established, language-agnostic
171+
standard, or for other reasons, if those reasons are properly justified
172+
and voted on as part of the RFC process.
173+
174+
175+
Good method names:
158176

159177
```php
160178
connect()
161179
getData()
162180
buildSomeWidget()
181+
performHttpRequest()
163182
```
164183

165-
Bad:
184+
Bad method names:
166185

167186
```php
168187
get_Data()
169188
buildsomewidget()
170189
getI()
190+
performHTTPRequest()
171191
```
172192

173-
1. Class names should be descriptive nouns in *PascalCase* and as short as
174-
possible. Each word in the class name should start with a capital letter,
175-
without underscore delimiters. The class name should be prefixed with the
176-
name of the "parent set" (e.g. the name of the extension) if no namespaces
177-
are used. Abbreviations and acronyms as well as initialisms should be
178-
avoided wherever possible, unless they are much more widely used than the
179-
long form (e.g. HTTP or URL). Abbreviations start with a capital letter
180-
followed by lowercase letters, whereas acronyms and initialisms are written
181-
according to their standard notation. Usage of acronyms and initialisms is
182-
not allowed if they are not widely adopted and recognized as such.
183-
184-
Good:
193+
Good class names:
185194

186195
```php
187196
Curl
188197
CurlResponse
189-
HTTPStatusCode
190-
URL
191-
BTreeMap // B-tree Map
192-
Id // Identifier
193-
ID // Identity Document
198+
HttpStatusCode
199+
Url
200+
BtreeMap // B-tree Map
201+
UserId // User Identifier
194202
Char // Character
195203
Intl // Internationalization
196-
Radar // Radio Detecting and Ranging
204+
Ssl\Certificate
205+
Ssl\Crl // Certificate Revocation List
206+
Ssl\CrlUrl
197207
```
198208

199-
Bad:
209+
Bad class names:
200210

201211
```php
202212
curl
203213
curl_response
204-
HttpStatusCode
205-
Url
206-
BtreeMap
207-
ID // Identifier
214+
HTTPStatusCode
215+
URL
216+
BTreeMap
217+
UserID // User Identifier
208218
CHAR
209219
INTL
210-
RADAR // Radio Detecting and Ranging
220+
SSL\Certificate
221+
SSL\CRL
222+
SSL\CRLURL
211223
```
212224

213225
## Internal function naming conventions

0 commit comments

Comments
 (0)