mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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>
This commit is contained in:
parent
70b5a4d554
commit
48971af482
1 changed files with 48 additions and 36 deletions
|
@ -152,62 +152,74 @@ rewritten to comply with these rules.
|
||||||
1. Method names follow the *studlyCaps* (also referred to as *bumpy case* or
|
1. Method names follow the *studlyCaps* (also referred to as *bumpy case* or
|
||||||
*camel caps*) naming convention, with care taken to minimize the letter
|
*camel caps*) naming convention, with care taken to minimize the letter
|
||||||
count. The initial letter of the name is lowercase, and each letter that
|
count. The initial letter of the name is lowercase, and each letter that
|
||||||
starts a new `word` is capitalized:
|
starts a new "word" is capitalized.
|
||||||
|
|
||||||
Good:
|
|
||||||
|
|
||||||
```php
|
|
||||||
connect()
|
|
||||||
getData()
|
|
||||||
buildSomeWidget()
|
|
||||||
```
|
|
||||||
|
|
||||||
Bad:
|
|
||||||
|
|
||||||
```php
|
|
||||||
get_Data()
|
|
||||||
buildsomewidget()
|
|
||||||
getI()
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Class names should be descriptive nouns in *PascalCase* and as short as
|
1. Class names should be descriptive nouns in *PascalCase* and as short as
|
||||||
possible. Each word in the class name should start with a capital letter,
|
possible. Each word in the class name should start with a capital letter,
|
||||||
without underscore delimiters. The class name should be prefixed with the
|
without underscore delimiters. The class name should be prefixed with the
|
||||||
name of the "parent set" (e.g. the name of the extension) if no namespaces
|
name of the "parent set" (e.g. the name of the extension) if no namespaces
|
||||||
are used. Abbreviations and acronyms as well as initialisms should be
|
are used.
|
||||||
avoided wherever possible, unless they are much more widely used than the
|
|
||||||
long form (e.g. HTTP or URL). Abbreviations start with a capital letter
|
|
||||||
followed by lowercase letters, whereas acronyms and initialisms are written
|
|
||||||
according to their standard notation. Usage of acronyms and initialisms is
|
|
||||||
not allowed if they are not widely adopted and recognized as such.
|
|
||||||
|
|
||||||
Good:
|
1. Abbreviations and acronyms as well as initialisms should be avoided wherever
|
||||||
|
possible, unless they are much more widely used than the long form (e.g. HTTP
|
||||||
|
or URL). Abbreviations, acronyms, and initialisms should be treated like
|
||||||
|
regular words, thus they should be written with an uppercase first character,
|
||||||
|
followed by lowercase characters.
|
||||||
|
|
||||||
|
1. Diverging from this policy is allowed to keep internal consistency within a
|
||||||
|
single extension, if the name follows an established, language-agnostic
|
||||||
|
standard, or for other reasons, if those reasons are properly justified
|
||||||
|
and voted on as part of the RFC process.
|
||||||
|
|
||||||
|
|
||||||
|
Good method names:
|
||||||
|
|
||||||
|
```php
|
||||||
|
connect()
|
||||||
|
getData()
|
||||||
|
buildSomeWidget()
|
||||||
|
performHttpRequest()
|
||||||
|
```
|
||||||
|
|
||||||
|
Bad method names:
|
||||||
|
|
||||||
|
```php
|
||||||
|
get_Data()
|
||||||
|
buildsomewidget()
|
||||||
|
getI()
|
||||||
|
performHTTPRequest()
|
||||||
|
```
|
||||||
|
|
||||||
|
Good class names:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
Curl
|
Curl
|
||||||
CurlResponse
|
CurlResponse
|
||||||
HTTPStatusCode
|
HttpStatusCode
|
||||||
URL
|
Url
|
||||||
BTreeMap // B-tree Map
|
BtreeMap // B-tree Map
|
||||||
Id // Identifier
|
UserId // User Identifier
|
||||||
ID // Identity Document
|
|
||||||
Char // Character
|
Char // Character
|
||||||
Intl // Internationalization
|
Intl // Internationalization
|
||||||
Radar // Radio Detecting and Ranging
|
Ssl\Certificate
|
||||||
|
Ssl\Crl // Certificate Revocation List
|
||||||
|
Ssl\CrlUrl
|
||||||
```
|
```
|
||||||
|
|
||||||
Bad:
|
Bad class names:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
curl
|
curl
|
||||||
curl_response
|
curl_response
|
||||||
HttpStatusCode
|
HTTPStatusCode
|
||||||
Url
|
URL
|
||||||
BtreeMap
|
BTreeMap
|
||||||
ID // Identifier
|
UserID // User Identifier
|
||||||
CHAR
|
CHAR
|
||||||
INTL
|
INTL
|
||||||
RADAR // Radio Detecting and Ranging
|
SSL\Certificate
|
||||||
|
SSL\CRL
|
||||||
|
SSL\CRLURL
|
||||||
```
|
```
|
||||||
|
|
||||||
## Internal function naming conventions
|
## Internal function naming conventions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue