aboutsummaryrefslogtreecommitdiff
path: root/documentation/coding_standards/php_coding_standards.txt
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-08-25 10:00:38 -0700
commitdccc333c765bb28da55b4a55d9c916acdb88413a (patch)
treebdd26a0b4cd85241a19b7fcb2c0770f0ac3eb9f0 /documentation/coding_standards/php_coding_standards.txt
parentec7b94a64aef23b85866ecdac8e8acc712d29bb6 (diff)
parent003cb81c7888f4d2fd763e5814027c6f8d71186f (diff)
downloadelgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.gz
elgg-dccc333c765bb28da55b4a55d9c916acdb88413a.tar.bz2
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'documentation/coding_standards/php_coding_standards.txt')
-rw-r--r--documentation/coding_standards/php_coding_standards.txt55
1 files changed, 55 insertions, 0 deletions
diff --git a/documentation/coding_standards/php_coding_standards.txt b/documentation/coding_standards/php_coding_standards.txt
new file mode 100644
index 000000000..b7adc5dd9
--- /dev/null
+++ b/documentation/coding_standards/php_coding_standards.txt
@@ -0,0 +1,55 @@
+*** PHP CODING STANDARDS ***
+
+These are the coding standards for Elgg. All core development and bundled
+plugins are required to be in this format. Plugin developers are strongly
+encouraged to adopt these standards.
+
+* Unix line endings.
+
+* Hard tabs, 4 character tab spacing.
+
+* No PHP shortcut tags ( <? or <?= or <% ).
+
+* PHPDoc comments on functions and classes (all methods; declared properties
+ when appropriate).
+
+* 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 (ACCESS_FRIENDS, $CONFIG).
+
+* Use underscores / camel case to separate standard English words in
+ functions, classes, and methods. (get_default_site(), ElggUser->isLoggedIn()).
+
+* Space functions like_this($required, $optional = TRUE).
+
+* Space keywords and constructs like this: if (FALSE) { ... }.
+
+* Correctly use spaces, quotes, and {}s in strings:
+ Bad (hard to read, misuse of quotes and {}s):
+ echo 'Hello, '.$name."! How is your {$time_of_day}?";
+
+ Good:
+ echo "Hello, $name! How is your $time_of_day?";
+
+* Line lengths should be reasonable. If you are writing lines over 100
+ characters on a line, please revise the code.
+
+* Use // or /* */ when commenting.
+
+* No closing PHP tag (?>) at EOF unless after a heredoc. (Avoids problems with
+ trailing whitespace. Required after heredoc by PHP.)