mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Added coding standards by request of @sekjun9878. Fixed #949 [gh#949]
This commit is contained in:
parent
273a74d566
commit
a0fac71385
@ -20,8 +20,53 @@ Before contributing to PocketMine-MP, please read this.
|
||||
* Use the [Pull Request](https://github.com/PocketMine/PocketMine-MP/pull/new) system, your request will be checked and discussed.
|
||||
* __Create a single branch for that pull request__
|
||||
* If you want to be part of PocketMine-MP, we will ask you to.
|
||||
* Code using the syntax as in PocketMine-MP.
|
||||
* Code using the syntax as in PocketMine-MP. See below for an example.
|
||||
* The code must be clear and written in English, comments included.
|
||||
|
||||
|
||||
__Thanks for contributing to PocketMine-MP!__
|
||||
|
||||
|
||||
|
||||
#### Code syntax
|
||||
|
||||
It is mainly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) with a few exceptions.
|
||||
* Opening braces MUST go on the same line.
|
||||
* `else if` MUST be written as `elseif`. _(It is in PSR-2, but using a SHOULD)_
|
||||
* Control structure keywords or opening braces MUST NOT have one space after them.
|
||||
* Code MUST use tabs for indenting.
|
||||
* Long arrays MAY be split across multiple lines, where each subsequent line is indented once.
|
||||
* Files MUST use only the `<?php` tag.
|
||||
* Files MUST NOT have an ending `?>` tag.
|
||||
* Code MUST NOT use namespaces. _(This restriction will be lifted on the Alpha_1.4 code)_
|
||||
* Strings SHOULD use the double quote `"` except when the single quote is required.
|
||||
* Arrays SHOULD be declared using `array()`, not the `[]` shortcut.
|
||||
* Argument lists MAY NOT be split across multiple lines, except long arrays.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
class ExampleClass{
|
||||
const EXAMPLE_CLASS_CONSTANT = 1;
|
||||
public $examplePublicVariable = "defaultValue";
|
||||
private $examplePrivateVariable;
|
||||
|
||||
public function __construct($firstArgument, &$secondArgument = null){
|
||||
if($firstArgument === "exampleValue"){ //Remember to use === instead == when possible
|
||||
//do things
|
||||
}elseif($firstArgument === "otherValue"){
|
||||
$secondArgument = function(){
|
||||
return array(
|
||||
0 => "value1",
|
||||
1 => "value2",
|
||||
2 => "value3",
|
||||
3 => "value4",
|
||||
4 => "value5",
|
||||
5 => "value6",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user