30,997
edits
m (→PHP) Tag: 2017 source edit |
mNo edit summary Tag: 2017 source edit |
||
| Line 84: | Line 84: | ||
* Coding style to use is the '''PSR-12''' (https://www.php-fig.org/psr/psr-12/). Only rules tagged "MUST" are currently required. So note however the exceptions: | * Coding style to use is the '''PSR-12''' (https://www.php-fig.org/psr/psr-12/). Only rules tagged "MUST" are currently required. So note however the exceptions: | ||
** Length of line: PSR- | ** Length of line: PSR-12 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". | ||
** We allow elements of an array on same line and we do not always add a new line at end of an array. So $var = array(1, 2, 4); will be like this | ** We allow elements of an array on same line and we do not always add a new line at end of an array. So $var = array(1, 2, 4); will be like this | ||
| Line 99: | Line 99: | ||
*** 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''' | ||
** Note 2: You can use the file '''dev/codesniffer/ruleset.xml''' as rule file to control coding style with PHPCodeSniffer. | ** Note 2: You can use the file '''dev/codesniffer/ruleset.xml''' as rule file to control coding style with PHPCodeSniffer. | ||
** Note 3: You may note that current code is not yet compliant with the PSR- | ** Note 3: You may note that current code is not yet compliant with the PSR-12. The reason is that we must "now" follow the "MUST" rules of PSR-12, but it wasn't in the past. So feel free to change coding style to match new rules (keep in mind the 2 exceptions) if you find such cases. | ||
== Classes and properties structures == | == Classes and properties structures == | ||