Improve coding standards

This commit is contained in:
Dennis Eichhorn 2018-02-06 20:01:56 +01:00
parent 1b94ba54b1
commit 88bfa37234
2 changed files with 32 additions and 1 deletions

View File

@ -118,6 +118,19 @@ if (...) {
$result = condition ? expr1 : expr2;
```
Multiline `if` statements must begin with a logical opperator `or`/`and`.
```php
if (isTrue == true
|| isFalse === false
&& isNotTrue !== true
) {
}
```
Switch statements must have a `default` case.
## Constants
Constants must be written with capital letters and snake case.

View File

@ -10,6 +10,14 @@ PHP code MUST use the long `<?php ?>` tags or the short-echo `<?= ?>` tags; it M
PHP code MUST use only UTF-8 without BOM
## Line Ending
Lines MUST end with `\n` (LF) and MUST NOT have a whitespace at the end.
## File Ending
Files must end with a new line element `\n`.
## Namespace and Class Names
Namespaces and classes MUST follow an "autoloading" PSR: [PSR-0, PSR-4].
@ -23,7 +31,7 @@ Class names MUST be declared in StudlyCaps.
Php code embedded into template files SHOULD use the alternative syntax for control structures in order to improve the readability:
```php
if($a === 5) : ?>
<?php if ($a === 5) : ?>
<p>This is html</p>
<?php endif; ?>
```
@ -36,6 +44,16 @@ when echoing multiple components, don't concat them but use `,`.
echo 'Hello' , 'World';
```
## If
#### Elseif
Use `elseif` where possible instead of `else if`.
## Namespace
Namespaces must be surrounded with new line elements.
## Deprecated functions and variables
The following functions and (super-) global variables MUST NOT be used.