per-coding-style icon indicating copy to clipboard operation
per-coding-style copied to clipboard

How should abbreviations and acronyms be written?

Open boan-jfm opened this issue 1 year ago • 11 comments

We have a recommendation to use StudlyCaps (PascalCase) naming in the PER:

PER

The term "StudlyCaps" in PSR-1 MUST be interpreted as PascalCase where the first letter of each word is capitalized including the very first letter. -- https://www.php-fig.org/per/coding-style/#2-general

Class names

Class names MUST be declared in StudlyCaps -- https://www.php-fig.org/psr/psr-1/#3-namespace-and-class-names

Method names

Method names MUST be declared in camelCase(). -- https://www.php-fig.org/psr/psr-1/#43-methods

But how should we write abbreviations and acronyms?

I suggest following camel case, e.g., loadHttpUrl as recommended in the "Google TypeScript Style Guide".

Google TypeScript Style Guide:

5.1.3 Camel case Treat abbreviations like acronyms in names as whole words, i.e. use loadHttpUrl, not loadHTTPURL, unless required by a platform name (e.g. XMLHttpRequest). -- https://google.github.io/styleguide/tsguide.html#camel-case

boan-jfm avatar Oct 23 '23 12:10 boan-jfm