
Copyright © 2007 Cédric Delfosse - Mandriva
| Revision History | ||
|---|---|---|
| Revision $Revision: 58 $ | $Date: 2007-10-04 18:26:31 +0200 (Thu, 04 Oct 2007) $ | $Author: cedric $ |
Abstract
Coding conventions for the PHP code of all MDS components
Table of Contents
This document sets the coding conventions for the PHP code of all MDS components (like the MMC web interface for example).
Convention from http://pear.php.net/manual/en/standards.php apply too.
Indentation: use 4 spaces per indentation level, no tabs allowed.
Encoding: the source code must always use the UTF-8 encoding.
For long html code, templates and views prefer using "short PHP tags":
<body>
<h1><?= $title ?></h1>
<ul>
<? foreach ($arr as $value) { ?>
<li><?= $value ?></li>
<? } ?>
</ul>
</body>
Code is more explicit and preserve html code source indentation.
block "for", "function", "switch", "if",etc... always end with opening braces on the same line.
if ($val == value) {
echo $val;
} else {
return -1;
}
foreach ($arrParam as $singleItem) {
print $singleItem;
}
Function with long args (more than one line size)
myFunction($value1,
$value2,
$morevalue4,
$val5);
They are written in english.
They always start with a capitalized first word.
There is always a space between the // and the begin of the comment. // and /* are fine. Don't use #.
All functions must have a correct doxygen header.