mirror of
https://github.com/Karaka-Management/Developer-Guide.git
synced 2026-01-11 20:38:42 +00:00
Improve coding standards
This commit is contained in:
parent
1b94ba54b1
commit
88bfa37234
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user