Sprachen und Programmierregeln: Difference between revisions

Jump to navigation Jump to search
Übersetzung
No edit summary
Tag: 2017 source edit
(Übersetzung)
Line 98: Line 98:
</source>
</source>


<br />
*Funktionen müssen bei Erfolg einen Wert zurückgeben, der größer/gleich 0 ist und bei Fehlern zwingend kleiner als 0 ist


*Functions must return a value equal or higher than 0 if successful and strictly lower than 0 if error.
*Es darf kein Code im Dolibarr-Kerncode vorhanden sein, welcher nur von Externen Modulen verwendet wird (Toter Code). Code von externen Modulen muss in den externen Modulen enthalten sein.  


*No dead code (code never used) into Dolibarr core code (code used by external modules only must be included within the external modules).
*Verwenden Sie "include_once" für alles, was Funktionen oder Klassendefinitionen enthält (wie * .class.php- und * .lib.php-Dateien), und "include" für PHP-Dateien im Vorlagenstil, die HTML- und PHP-Code enthalten (wie * .inc.php und * .tpl.php Dateien).


*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).
*Der zu verwendende Codierungsstil ist '''PSR-12''' (https://www.php-fig.org/psr/psr-12/). Nur die Regeln, welche mit "Muss" gekennzeichnet sind, sind absolut zwingend. Beachten Sie die folgenden Ausnahmen:
 
*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-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).
**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".

Navigation menu