Star2Billing/a2billing — pull request #29 by miken32 (2012-08-28 19:11:03+00:00)
Title: Code standards

Following up from [my forum post] (http://forum.asterisk2billing.org/viewtopic.php?f=18&t=9556) here are some proposed changes to clean up some of the code. Looking at the code, it seems like it started out following [PEAR standards] (http://pear.php.net/manual/en/standards.php) pretty closely, so that's what I used as a guide. This is what I would call a first step, the changes are entirely to whitespace:

* 4 space indentation
* aligned blocks of assignments where practical
* no spaces between function name and opening parenthesis
* spaces around control structure parentheses
* spaces around binary and ternary operators
* no spaces around unary operators, object and array operators
* no spaces inside parentheses
* spaces after commas

To reiterate, these are all changes to whitespace only. Running "diff -w" between this branch and the master branch should show no changes.

The next step would be changes to the actual code:
* shortening long (100+) lines
* consistent use of K&R braces especially around 1-line `if` statements
* elimination of unnecessary concatenation operators with use of double quoted strings
* documentation blocks for all classes/procedures
* removal of commented code and any unnecessary test code
* ...?

This is a work in progress, I'd love to get feedback, and to know that I haven't wasted a few hours! I think that any successful project should have extensive coding standards in place, and enforce them. Other open source projects, for example, will not accept patches that don't conform to project standards. I believe this is especially important for line indentation; some lines I fixed here had a mix of tabs, 4 space, and 8 space indentation *on the same line*! This results in a totally inconsistent experience for code contributors.