Table of Contents

There has been a discussion on new coding standards for PHP5 object orientation on the Mailing list:

Coding Guidelines

First, read the PHP Coding Standard by Fredrik Kristiansen (who happens to recommend Mantis for bugtracking). The rest of this page describes in which ways we differ, as well as other Mantis-specific guidelines.

Please discuss any omissions or disagreements on our Gitter chat room, or in the Forums.

General Formatting


Code Blocks

Braces and Parentheses


while( while_condition ) {
  ... lots of code ...
  if( blah_condition ) {
    for( ... ) {
    ... lots of code ...
  } # end blah if
  ... lots of code ...
  if( cond1 ) {
  } else if( cond2 ) {
    something two
  } else {
    something else
} # end while true


To facilitate reading of complex conditions, you can either:

Switch statements

Every case must have a break or another kind of exit statement, e.g. return, die, etc. If falling through to the following case is intended, it must be documented, unless the case does not contain any code. The break is not necessary for the final, default case.

switch( condition ) {
    case 1:
    case 2:
        # Fall through must be commented
    case 3:        # No need for a break here
    case 4:
        return;    # No need for a break here


File Names

Always include the standard header at the top of the file.

Classes Names

Function Names

Variables Names


Do not use q, o, i, or l for prefixes as they are visually confusing and prone to being mistaken for each other or existing prefixes.

Counters and Loop variables

Other Variables

SQL Formatting


Tables should be wrapped a table-container:1)

<div class="table-container"><table><!-- ... --></table></div>