30,997
edits
m (→PHP Norms) Tag: 2017 source edit |
m (→Comments) Tag: 2017 source edit |
||
| Line 108: | Line 108: | ||
**Note 1: The following rule are very important to follow: | **Note 1: The following rule are very important to follow: | ||
***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. | ***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 must not be used. PHP code section must start with '''<?php''' (smart tags, also known as short tags depend on php configuration option short_open_tag | ***Smart tags PHP must not be used. PHP code section must start with '''<?php''' (the "smart tags" <? or <?=, also known as the "short tags", depend on php configuration option '''short_open_tag'''. Even if this was solved after php5.4, the use of <? can still have conflict with XML syntax. The smartags may not be supported by all IDE. Also, the use of <?= make easier for a hacker to make PHP injection. To fight this, some Dolibarr components, like the website PHP editor, accepts only full php tags to detect, parse and filter PHP. Finaly, using the same tag everywhere make also easier to make code scanning or impact analysis when we are sure of the tags that is used, and the best solution, to be sure of which tag is used, is to use one, only one and the same tag everywhere. | ||
**Note 2: You can use the file '''dev/setup/codesniffer/ruleset.xml''' as rule file to control coding style with PHPCodeSniffer. | **Note 2: You can use the file '''dev/setup/codesniffer/ruleset.xml''' as rule file to control coding style with PHPCodeSniffer. | ||
**Note 3: You can use the file '''dev/setup/eclipse/PSR-12 [built-in].xml''' as rule file to setup Eclipse syntax formater. | **Note 3: You can use the file '''dev/setup/eclipse/PSR-12 [built-in].xml''' as rule file to setup Eclipse syntax formater. | ||