From a0fac713850228ec1e0a305d6957a162a7fec3bf Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 25 Nov 2013 18:34:06 +0100 Subject: [PATCH] Added coding standards by request of @sekjun9878. Fixed #949 [gh#949] --- CONTRIBUTING.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6e91d1d1..3ed56083 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 `` 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 + "value1", + 1 => "value2", + 2 => "value3", + 3 => "value4", + 4 => "value5", + 5 => "value6", + ); + } + } + } + +} +``` \ No newline at end of file