We encourage ActionApps developers to follow the coding standards described bellow. It help us to have the code as readable as possible for everyone.
Most of the following rules comes from php PEAR standard https://pear.php.net/manual/en/standards.php
Most important rules on the top:
If we mix both modes, the Subversion (svn) diffs are not useful
Do not use Tabs or use 'insert Tabs as spaces' option of your text editor. Most of the editors (like Jedit or HomeSite) allows it. Then the code will look good in any editor.
Do not use any other shorted version like <?, .. There are some problems on some Apache configurations with <?...
See https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md
- use /* */
and //
for comments, not #
if ((condition1) || (condition2)) {
commands;
} else {
commands;
}
- open brace at the end of lineif
, while
, ... separated by space (it is not function call)
function($var1, $var2=true)
No space between function name and open brace allow us easier find the function in the code.
AA_
prefix, words separated by underscore and first letters are in upper case
Just like - AA_Optimize_Db_Relation_Dups
- no
nor
AA_Optimize_DB_Relation_DupsAA_OptimizeDbRelationDups
Just like NormalizeArrayIndex()
, ParseClassProperties()
Just like $widget->getClassProperties()
, $property->isRequired()
Just like $this->_finalizaAjaxHtml
, $this->_selected
Just like $input_id
, $use_name
Try to write the code 80 characters wide, if possible.
Always quote strings like
'name'
in $arr['name']
or $db->f('name')
although current PHP do not need it.
$_GET
, $_POST
, and $_SERVER
Use mentioned superglobal arrays to access variables from forms ...
Return is the statement, not a function.
No private hacks for site XY
I know the current code do not strictly follows mentioned rules, but from this time it will ....... hopefully
Honza Malik, 1/29/2003