Coding Standards

From Habari Project

Jump to: navigation, search

These are the Coding Standards for Habari:

  • Use tabs instead of spaces for indentation
  • for functions and classes, the opening brace { should be on its own line
  • conditionals have the opening brace on the same line: if ( foo == bar ) {
  • on an else condition, closing brace on new line, else and opening brace on same line: } ''[line break]'' else {
  • Classes are named like so: ClassName UpperCamelCase
  • Variables are named with underscores: variable_name
  • spaces inside parentheses and operators: ( parentheses ), foo == bar
  • spaces before and after assignment: $foo = bar
  • Single line comments should use the // comment format; multi-line comments should use the /* */ format
  • Calls through the DB class should use the brace syntax for table names: DB::query( 'SELECT * FROM {table}' );
  • Where HTML and PHP is mixed in templates, PHP's alternative control syntax should be used.
Other Development Pages · Developer Introduction
Personal tools