Elgg Core and Plugin Coding Standards: Revision

Last updated by Brett
  1. Unix style line endings
  2. Hard tabs, 4 chars.
  3. No shortcut tags ( <? or <?= or <% )
  4. PHPDoc comments on functions and classes (including methods and declared members).
  5. {}s mandatory around any code block > 1 line or statement:
  6. Functions named using underscore_character().
  7. Classes named using CamelCase()
  8. Globals are ALL_CAPS.
  9. function_spaced($like_this, $and_this)
  10. Keywords spaced like this: if (false) { ... }
  11. Private methods don't need a preceding _
  12. Constants in caps (FALSE, TRUE, NULL, ACCESS_FRIENDS)
  13. Use single quotes for text without vars; double quotes for text with vars. (eg echo 'Hello!  How are you?'; vs echo "Hello, $name!  How are you?";
  14. Line lengths should be reasonable.  If you are writing lines over 120 characters, please revise the code.
  15. Preferred no closing ?> tag. (Avoids problems with trailing whitespace.)
  16. Preferred C-style comments (slashes)

History