aboutsummaryrefslogtreecommitdiff
path: root/CODING.txt
blob: 8442129252ff3b0292d3442cbdfb6b5636afac72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
These are the coding standards for Elgg.  All core development, bundled 
plugins, and tickets attached to Trac are expected to be in this format.

* Unix line endings
* Hard tabs, 4 character tab spacing.
* No shortcut tags ( <? or <?= or <% )
* PHPDoc comments on functions and classes (including methods and declared 
  members).
* Mandatory wrapped {}s around any code blocks. 
	Bad:
	if (true)
		foreach($arr as $elem)
			echo $elem;

	Good:
	if (true) {
		foreach($arr as $elem) {
			echo $elem;
		}
	}
* Name standalone functions using underscore_character().
* Name classes using CamelCase() and methods using lowerCamelCase().
* Name globals and constants in ALL_CAPS (FALSE, TRUE, NULL, ACCESS_FRIENDS, 
  $CONFIG).
* Space functions like_this($required, $optional = TRUE)
* Space keywords and constructs like this: if (false) { ... }
* Include variables in strings with double quotes instead of concatenating:
	Bad: 
	echo 'Hello, ' . $name . '!  How are you?';
	
	Good:
	echo "Hello, $name!  How are you?"; 
	
* Line lengths should be reasonable.  If you are writing lines over 100 
  characters, please revise the code.
* Use slash-style comments. (// and /* */)
* Preferred no closing ?> tag at EOF. (Avoids problems with trailing 
  whitespace.)