Changes

no edit summary
Line 33: Line 33:  
* When several variables must be initialized with the same value, you must use individual declarations (separated by ;)
 
* When several variables must be initialized with the same value, you must use individual declarations (separated by ;)
 
<source lang="php">
 
<source lang="php">
$var1=1;$var2=1;$var3=1;
+
$var1=1;
 +
$var2=1;
 +
$var3=1;
 
</source>
 
</source>
 
instead of
 
instead of
Line 56: Line 58:  
$result=$monobjet->fetch($idobject);
 
$result=$monobjet->fetch($idobject);
   −
for ($i = 1 , $i < 2 ; $i++)
+
for ($i = 1 , $i < 2 ; $i++) {
{
   
   // comment on one line
 
   // comment on one line
 
   print $i;
 
   print $i;
Line 70: Line 71:  
* Use "include_once" for anything with functions or class definitions in it (like *.class.php and *.lib.php files), use "include" for template-style php with files containing common part of HTML and PHP code (like *.inc.php and *.tpl.php files).
 
* Use "include_once" for anything with functions or class definitions in it (like *.class.php and *.lib.php files), use "include" for template-style php with files containing common part of HTML and PHP code (like *.inc.php and *.tpl.php files).
   −
* Coding style to use is the PSR-2 (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). Only rules tagged "MUST" are currently required. So note however the exceptions:
+
* Coding style to use is the '''PSR-2''' (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). Only rules tagged "MUST" are currently required. So note however the exceptions:
 
** Length of line: PSR-2 mention we can't go up to 120 characters on same line, this is a soft limit. It is better to have long lines instead of long page with code content that is just data declaration and does not contain any logic. However, we introduced a hard limit of '''1000''' characters (having line larger than this may return errors on Continuous Integration tests).  
 
** Length of line: PSR-2 mention we can't go up to 120 characters on same line, this is a soft limit. It is better to have long lines instead of long page with code content that is just data declaration and does not contain any logic. However, we introduced a hard limit of '''1000''' characters (having line larger than this may return errors on Continuous Integration tests).  
 
** Tabs are allowed: The other exception is that we don't replace systematically the tabs with spaces. Using tabs is more convenient for most editors/developers. Also using spaces breaks some auto-format features (like Eclipse autoformat feature on some Eclipse version). For the moment, the best setup is "Keep spaces/tabs as it is", however, you can activate the option "Remove spaces at end of lines".
 
** Tabs are allowed: The other exception is that we don't replace systematically the tabs with spaces. Using tabs is more convenient for most editors/developers. Also using spaces breaks some auto-format features (like Eclipse autoformat feature on some Eclipse version). For the moment, the best setup is "Keep spaces/tabs as it is", however, you can activate the option "Remove spaces at end of lines".