In order to make code easier to read, I (Alain Peyrat) would like to propose community to adopt common coding rules. The original ones (described in the gforge manual) are quite old now.
My proposal is to use the start from coding style recommendations made by the Framework Interop Group (formerly known as the ‘PHP Standards Group’). The rules are known as PSR-0, PSR-1 and PSR-2.
To adapt the code to new coding rules, there are some script available. For example, php-cs-fixer seems good and fast.
Initial proposal is (based on php-cs-fixer features):
indentation [PSR-2] Code must use 4 spaces for indenting, not tabs.(mirabilos, please keep it to one tab as indentation, 4 spaces for continuing lines, like https://www.mirbsd.org/man9/style and the Linux Kernel Coding Style, everything else is pythonic; note I’ll submit a counter proposal next week)
- linefeed [PSR-2] All PHP files must use the Unix LF (linefeed) line ending.
- trailing_spaces [PSR-2] Remove trailing whitespace at the end of lines.
- unused_use [all] Unused use statements must be removed.
- php_closing_tag [PSR-2] The closing ?> tag MUST be omitted from files containing only PHP.
- short_tag [PSR-1] PHP code must use the long <?php ?> tags or the short-echo <?= ?> tags; it must not use the other tag variations.
- return [all] An empty line feed should precede a return statement.
- visibility [PSR-2] Visibility must be declared on all properties and methods; abstract and final must be declared before the visibility; static must be declared after the visibility.
- braces [PSR-2]
Opening braces for classes and methods must go on the next line, andclosing braces must go on the next line after the body. Opening braces for control structures must go on the same line, and closing braces must go on the next line after the body.
- phpdoc_params [all] All items of the @param phpdoc tags must be aligned vertically.
- eof_ending [all] A file must always ends with an empty line feed.
- extra_empty_lines [all] Removes extra empty lines.
- include [all] Include and file path should be devided with single space. File path should not be placed under brackets.
psr0 [PSR-0] Classes must be in a path that matches their namespace, be at least one namespace deep, and the class name should match the file name.(Alain Peyrat, risky change)
- controls_spaces [all] A single space should be between: the closing brace and the control, the control and the opening parenthese, the closing parenthese and the opening brace.
- elseif [PSR-2] The keyword elseif should be used instead of else if so that all control keywords looks like single words.
Please strike rules that you disagree with (with name and a short comment).