You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ISPConfig is a open source project and community contributions are very welcome. To contribute, please stick to the guidelines.
2
3
3
-
The master branch is used for code (mostly new features) that shall go into the next major release (e.g. 3.2, 3.3 and so on). The stable branch (e.g. stable-3.1, stable-3.2) is the branch for the current intermediate and bugfix releases. Bugfixes shall be committed to the current stable branch and not the master branch. The stable branch is merged to the master automatically from time to time, please do not submit bugfixes a second time against the master.
4
+
This document is under development and will be continuously improved.
5
+
6
+
# Issues
7
+
* Before opening a new issue, use the search function to check if there isn't a bug report / feature request already.
8
+
* If you are reporting a bug, please share your OS and PHP (CLI) version.
9
+
* If you want to report several bugs or request several features, open a separate issue for each one of them.
10
+
11
+
# Branches
12
+
* Please create an issue for each contribution you want to make.
13
+
* Do not put multiple contributions into a single branch and merge request. Each contribution should have it's own branch.
14
+
* Do not use the develop branch in your forked project for your contribution. Create a separate branch for each issue.
15
+
* Give your branch a name, e. g. `6049-update-the-contributing-doc ` where 6049 is the issue number.
16
+
17
+
# Merge requests
18
+
Please give your merge request a description that shortly states what it is about. Merge requests without a good title or with missing description will get delayed because it is more effort for us to check the meaning of the changes made.
19
+
Once again: Do not put multiple things into a single merge request. If you for example fix two issues where one affects apache and one mail users, use separate issues and separate merge requests.
20
+
You can group multiple issues in a single merge request if they have the same specific topic, e. g. if you have one issue stating that a language entry in mail users is missing and a second issue that a language entry for server config is missing, you can put both issues into a single branch and merge request. Be sure to include all issue ids (if multiple) into the merge request's description in this case.
21
+
* Open a issue for the bug you want to fix / the feature you want to implement
22
+
* After opening the issue, commit your changes to your branch
23
+
* Note the issue # in every commit
24
+
* Update the documentation (New devs will not have access to this. Please send a email to docs@ispconfig.org)
25
+
* Add translations for every language
26
+
* Use a short title
27
+
* Write a clear description - for example, when updating the contributing guidelines with issue #6049: \
28
+
"Update of our contributing guidelines \
29
+
Closes #6049"
30
+
* Please be aware that we are not able to accept merge request that do not stick to the coding guidelines. We need to insist on that to keep the code clean and maintainable.
* Unix Line Breaks Only, NO windows breaks please.
8
-
* Tabs to indent lines, NO spaces
9
-
* no accidental _<?php space before, within or after a file
10
-
* every PHP file starts and end with <?php ?> no spaces before or after
11
-
* error_reporting(E_ALL|E_STRICT), yep PHP 5
12
-
* Magic quotes is gone, get used to it now. config = magic_quotes_gpc() Everything must be quoted
13
-
* Don't use ereg, split and other old function -> gone in PHP 5.4
14
-
* Don't use features that are not supported in PHP 5.3, for compatibility with LTS OS releases, ISPConfig must support PHP 5.3+
15
-
* Don't use shorttags. A Shorttag is <? and that is confusing with <?xml -> always use <?php
34
+
* Don't use features that are not supported in PHP 5.4, for compatibility with LTS OS releases, ISPConfig must support PHP 5.4+
35
+
* Don't use shorttags. A Shorttag is `<?` and that is confusing with `<?xml` -> always use `<?php`
16
36
* Don't use namespaces
17
37
* Column names in database tables and database table names are in lowercase
18
38
* Classes for the interface are located in interface/lib/classes/ and loaded with $app->uses() or $app->load() functions.
19
39
* Classes for the server are located in server/lib/classes/ and loaded with $app->uses() or $app->load() functions.
20
-
* please mark any section that need review or work on with /* TODO: short description */
21
-
* Make function / var names on the following way, first word lower, next word(s) first letter upper like. getFirstResult();
22
-
* always a space but NO newline before opening braces, e. g.
23
-
```
24
-
class abc {
25
-
public function cde() {
26
-
if($a == $b) {
27
-
return false;
28
-
}
29
-
}
40
+
41
+
### Indentations
42
+
43
+
Indentations are always done with tabs. Do **not** use spaces.
44
+
It is recommended to set your IDE to display tabs with a width of 4 spaces.
45
+
46
+
### Variable and method / function names
47
+
48
+
Methods and functions should always be written in camel-case. Variables and properties should always be lowercase instead.
49
+
50
+
**Correct:**
51
+
```php
52
+
class MyClass {
53
+
private $issue_list = [];
54
+
55
+
private function getMyValue() {
56
+
57
+
}
30
58
}
31
59
```
32
-
* no spaces after function/method or control names, e. g.
33
-
```
34
-
function abc($x, $y) {
35
-
if($condition == true) {
36
-
$x = 2;
37
-
}
60
+
61
+
**Wrong:**
62
+
```php
63
+
class my_class {
64
+
private $IssueList = [];
65
+
66
+
private function get_my_value() {
67
+
68
+
}
38
69
}
39
70
```
40
-
and NOT
71
+
72
+
### Blocks
73
+
74
+
#### Curly braces
75
+
76
+
Opening curly braces always have to be in the same line as the preceding condition. They are separated by a single space from the closing paranthesis.
77
+
Closing curly braces are always on a separate line after the last statement in the block. The only exception is a do-while block where the logic is inverted.
78
+
79
+
Curly braces are **always** to be used. Do not leave them out, even if there is only a single statement in the corresponding block.
80
+
81
+
**Correct:**
82
+
```php
83
+
if($variable === true) {
84
+
85
+
}
86
+
87
+
while($condition) {
88
+
89
+
}
90
+
91
+
do {
92
+
93
+
} while($condition);
41
94
```
42
-
function abc ($x, $y) {
43
-
if ( $condition == true ) {
44
-
45
-
}
95
+
96
+
**Wrong:**
97
+
```php
98
+
if($variable === true){
99
+
100
+
}
101
+
102
+
if($variable === true)
103
+
{
104
+
46
105
}
106
+
107
+
if($variable === true)
108
+
$x = 'no braces';
109
+
110
+
while($condition) { }
47
111
```
48
112
49
-
# Commenting style
113
+
#### Short style
114
+
115
+
The short style of conditional assignments is allowed to be used, but it must not affect readability, e. g. they shall not be nested.
as this function is self-explaining, the following clean code will suffice
182
+
This must not be abused, e. g. the following is not allowed:
183
+
184
+
```php
185
+
if($a == 1
186
+
|| $b == 2) {
187
+
188
+
}
87
189
```
88
-
function login($user, $pass){
89
-
90
-
}
190
+
191
+
### Arrays
192
+
193
+
#### Short syntax
194
+
195
+
Please **do** use short array syntax. We have deprecated the old-style array syntax.
196
+
197
+
**Correct**:
198
+
```php
199
+
$var = [];
200
+
201
+
$var2 = [
202
+
'conf' => [
203
+
'setting1' => 'value1'
204
+
]
205
+
];
91
206
```
92
207
93
-
# Where to store custom settings
208
+
**Wrong:**
209
+
```php
210
+
$var = array();
94
211
95
-
## Interface settings
212
+
$var2 = array(
213
+
'conf' => array(
214
+
'setting1' => 'value1'
215
+
)
216
+
);
217
+
```
218
+
219
+
#### Spaces and newlines
220
+
221
+
When defining an empty array, both brackets shall be on the same line. When defining an array with values, the style depends on the values you are going to assign.
222
+
223
+
##### List of values
224
+
225
+
When defining an array with a list of values, e. g. numbers or names, they should be on the same line as the brackets without using new lines, as long as the line does not exceed a total number of characters of about 90. After each comma there has to be a single space.
226
+
227
+
##### Nested array
228
+
229
+
When defining a nested array onle the opening bracket is to be on the same line. The closing bracket has to be on a separate line indented by `tabs * level of array`.
230
+
231
+
##### Examples
232
+
233
+
```php
234
+
// empty array
235
+
$a = [];
96
236
237
+
// array with list of values
238
+
$array = [4, 3, 76, 12];
239
+
240
+
// array with long list of values
241
+
$array = [
242
+
'This is one entry', 'This is a second one', 'Another one', 'Further entries', 'foo', 'bar', 34, 42, $variable, // newline here for better readability
0 commit comments