Changes

m
Line 66: Line 66:  
* Functions must return a value strictly higher than 0 if successful and strictly lower than 0 if error.
 
* Functions must return a value strictly higher than 0 if successful and strictly lower than 0 if error.
   −
* No dead code (code never used) into Dolibarr core code (code used by external modules only must be included into external modules).
+
* No dead code (code never used) into Dolibarr core code (code used by external modules only must be included within the external modules).
   −
* Use "include_once" for anything with functions or class definitions in it (so *.class.php and *.lib.php files), use "include" for template-style php with files containing a mix of HTML and PHP (so *.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 a mix of HTML and PHP (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) with 2 exceptions, this means:
 
* Coding style to use is the PSR-2 (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) with 2 exceptions, this means:
** Files must be saved with Unix format (LF) and not Windows (CR/LF). Unif format is compatible on all OS like Unix like, Windows, Mac, but the Windows text file format is no working on some PHP under Unix.
+
** Files must be saved with Unix format (LF) and not Windows (CR/LF). Unix format is compatible on all OS such as Unix like, Windows, Mac, but the Windows text file format may not work on some PHP under Unix.
 
** Smart tags PHP are not used. PHP code section must start with '''<?php'''
 
** Smart tags PHP are not used. PHP code section must start with '''<?php'''
** But there is an exception of length of line: We accept more than 80 characters per line. 80 is really to low. In most cases, we never go over 80, but sometimes (when declaring a list of reference arrays, like into module descriptor files), it is better to have long lines instead of long page with code content that is just data declaration and does not contains any logic.
+
** But there is an exception of length of line: We accept more than 80 characters per line. 80 is really too low. In most cases, we never go over 80, but sometimes (when declaring a list of reference arrays, like in the module descriptor files), 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.
 
** The other exception is that we don't replace the tab with space. This makes lot of editor crazy and breaks some auto-format features.
 
** The other exception is that we don't replace the tab with space. This makes lot of editor crazy and breaks some auto-format features.
 
You can use the file dev/codesniffer/ruleset.xml as rule file to control coding style with PHPCodeSniffer.
 
You can use the file dev/codesniffer/ruleset.xml as rule file to control coding style with PHPCodeSniffer.
304

edits