There doesn't seem to be (or I can't find) any PSR guidance on the use of acronyms in class names.
In the wider programming world, the idiomatic way of naming is mixed. Go thinks you should use all capitals but C# says only capitalise the first letter.
I struggle with this also, always questioning myself. Did I name the function photoUrl() or photoURL() ?
I think in the main, I tend to stick with capitalising only the first letter, but I'm guilty of not being consistent.
This from 2017 identifies the issue and shows that the PHP contributors were split in their thinking https://wiki.php.net/rfc/class-naming so, with no change to PSR-1 I guess it's left to us to decide.
PSR-1 states that we should use StudlyCaps for class names and camelCase for method names, but does not define either or how initialisations and acronyms should be treated.
@topvillas@snapey I only capitalise the first letter in initials (so photoUrl, LoginDto, etc) just for the simple reason of, if for some reason you tried to automatically convert it to snake_case, it would come out as photo_u_r_l, login_d_t_o, etc which probably isn’t what you want.
Same here. Additonally to the above reasons it just looks weird (and is hard to read) if the name doesn't end after the acronym and you end up with something like photoURLFoo, LoginDTOBar.
In general naming convention cases, the most frequent convention I tend to follow is for .NET C#
The PascalCasing convention, used for all identifiers except parameter names, capitalizes the first character of each word (including acronyms over two letters in length), as shown in the following examples:
PropertyDescriptorHtmlTag
A special case is made for two-letter acronyms in which both letters are capitalized, as shown in the following identifier:
IOStream
The camelCasing convention, used only for parameter names, capitalizes the first character of each word except the first word, as shown in the following examples. As the example also shows, two-letter acronyms that begin a camel-cased identifier are both lowercase.
You can see examples of this convention in Laravel itself, i.e. the controllers directory is in a Http namespace and not a “HTTP” namespace, the HTTP client facade is named Http and not “HTTP”, and so on.
@martinbean thank you for the response! I see. It makes sense also in the scope of PSR-4 with the auto-loader associating the namespaces to the file-system, indeed! What do you think about acronyms/abbreviations of 2 characters?