Project

General

Profile

StandardsNaming » History » Version 1

Vasily Bezruchkin, August 01, 2012 04:42

1 1 Vasily Bezruchkin
h1. Naming Conventions
2
3
h2. Classes
4
5
Classes should be given descriptive names. Avoid using abbreviations where possible. Use upper case letters as word separators (CamelCase), lower case for the rest of a word. Don't use underbars.
6
7
<pre><code class="php">
8
class Name
9
{
10
}
11
12
class SomeCompoundName
13
{
14
}
15
</code></pre>
16
17
18
h2. Functions and Methods
19
20
Functions and methods should be named using the "studly caps" style (also referred to as "bumpy case" or "camel caps"). The initial letter of the name (after the prefix) is lowercase, and each letter that starts a new "word" is capitalized.
21
22
h2. Constants
23
24
Constants should always be all-uppercase, with underscores to separate words. We highly recommend to use a prefix for the constants. It's a common practice to use *IA_* for Subrion CMS project constants.
25
26
*Note:* The true, false and null constants are excepted from the all-uppercase rule, and must always be lowercase.
27
28
h2. Global Variables
29
30
All the global variables are stored in the $GLOBALS array. All the words in the name are uppercased with underbars as separators. E.g. $GLOBALS['MY_GLOBAL_VAR'].
31
32
33
h2. Hook Names
34
35
The name of hooks should be intuitively obvious and should be show where hook is placed.
36
37
Recommendation name of hook:
38
39
<pre>
40
typePartFileWhereWhat
41
</pre>
42
43
* *type* - the type of hook (php | smarty). It could be PHP or SMARTY hook.
44
* *part* - the part of script (front | admin). In what part of script the hook.
45
* *file* - the name of file in where hook is placed.
46
* *where* - the place of any part of file. (after | before).
47
* *what* - the part of file.
48
49
Examples:
50
_phpFrontHeaderBeforeListingFieldsDisplay_ - It is the common PHP hook in the front end and it is placed before listings fields display action.