mirror of
https://github.com/Karaka-Management/Developer-Guide.git
synced 2026-01-28 11:58:41 +00:00
Improve coding standards
This commit is contained in:
parent
1b94ba54b1
commit
88bfa37234
|
|
@ -118,6 +118,19 @@ if (...) {
|
||||||
$result = condition ? expr1 : expr2;
|
$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
|
||||||
|
|
||||||
Constants must be written with capital letters and snake case.
|
Constants must be written with capital letters and snake case.
|
||||||
|
|
|
||||||
|
|
@ -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
|
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
|
## Namespace and Class Names
|
||||||
|
|
||||||
Namespaces and classes MUST follow an "autoloading" PSR: [PSR-0, PSR-4].
|
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 code embedded into template files SHOULD use the alternative syntax for control structures in order to improve the readability:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
if($a === 5) : ?>
|
<?php if ($a === 5) : ?>
|
||||||
<p>This is html</p>
|
<p>This is html</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
```
|
```
|
||||||
|
|
@ -36,6 +44,16 @@ when echoing multiple components, don't concat them but use `,`.
|
||||||
echo 'Hello' , 'World';
|
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
|
## Deprecated functions and variables
|
||||||
|
|
||||||
The following functions and (super-) global variables MUST NOT be used.
|
The following functions and (super-) global variables MUST NOT be used.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user