Skip to content

Commit 75124b0

Browse files
author
Marius Burkard
committed
Merge branch 'stable-3.1'
2 parents 45e9406 + 33f1938 commit 75124b0

File tree

1 file changed

+39
-55
lines changed

1 file changed

+39
-55
lines changed

CODING_NOTES.php.txt

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,67 @@
1-
Some guidelines for web development with php.
1+
Some guidelines for web development with PHP.
22
-----------------------------------------------------
33
* Unix Line Breaks Only, NO windows breaks please.
4-
* Tabs set at 4 spaces either as tabs or spaces.
4+
* Tabs to indent lines, NO spaces
55
* no accidental _<?php space before, within or after a file
6-
* every php file starts and end with <?php ?> no spaces before or after
7-
* error_reporting(E_ALL|E_STRICT) , yep php5
8-
* Magic quotes is gone in php6, get used to it now. config = magic_quotes_gpc() Everything must be quoted
9-
* Don't use ereg,split and other old function -> gone in php 5.4 or 6 (different information on php.net) http://www.php.net/manual/en/migration53.deprecated.php
10-
* Don't use shorttags. A Shorttag is <? and that is confusing with <?xml -> always <?php
6+
* every PHP file starts and end with <?php ?> no spaces before or after
7+
* error_reporting(E_ALL|E_STRICT), yep PHP 5
8+
* Magic quotes is gone, get used to it now. config = magic_quotes_gpc() Everything must be quoted
9+
* Don't use ereg, split and other old function -> gone in PHP 5.4
10+
* Don't use features that are not supported in PHP 5.3, for compatibility with LTS OS releases, ISPConfig must support PHP 5.3+
11+
* Don't use shorttags. A Shorttag is <? and that is confusing with <?xml -> always usw <?php
12+
* Don't use namespaces
1113
* Column names in database tables and database table names are in lowercase
1214
* Classes for the interface are located in interface/lib/classes/ and loaded with $app->uses() or $app->load() functions.
1315
* Classes for the server are located in server/lib/classes/ and loaded with $app->uses() or $app->load() functions.
14-
15-
please mark any section that need review or work on with
16-
// TODO
17-
* Add documentation about access levels (public, private, protected).
16+
* please mark any section that need review or work on with /* TODO: short description */
1817
* Make function / var names on the following way, first word lower, next word(s) first letter upper like. getFirstResult();
19-
20-
Pear coding guidelines
18+
* always a space but NO newline before opening braces, e. g.
19+
class abc {
20+
public function cde() {
21+
if($a == $b) {
22+
return false;
23+
}
24+
}
25+
}
26+
* no spaces after function/method or control names, e. g.
27+
function abc($x, $y) {
28+
if($condition == true) {
29+
$x = 2;
30+
}
31+
}
32+
and NOT
33+
function abc ($x, $y) {
34+
if ( $condition == true ) {
35+
36+
}
37+
}
2138

2239
//*****************************************************************************
2340
// Commenting style
2441
//*****************************************************************************
25-
phpdoc is used for creating and autogenerating the documentation, this means that
26-
some of the comments can be formatted to be included in documentation.
27-
ie the source files are scanned then processed and html docs are created.
2842

2943
The comments break down into the following types
3044
// is uses for removing lines and debug dev etc
31-
//** and //* are used as "sub comments"
3245
/*
33-
is used to comment out blocks
46+
is used to comment out blocks
3447
*/
48+
3549
/** is used to create documentaion
36-
* thats over
37-
* lines
38-
*/
50+
* thats over
51+
* lines
52+
*/
3953

4054
If you need to block out a section then use
4155
/*
4256
function redundant_code(){
43-
something here
57+
something here
4458
}
4559
*/
4660

4761
To block out single lines use // and all // are assumed to be redundant test code and NOT comments
4862

4963
// print_r($foo);
5064

51-
For inline comment use //** and //* eg
52-
53-
//** Decide what do do
54-
switch($decide){
55-
//* blow it up
56-
case 'baloon':
57-
$foo->gas(+1);
58-
// test_pressure(); << inline comment
59-
break;
60-
61-
//* Do default action
62-
default:
63-
do_land();
64-
get_gps();
65-
//* following grant greaceful exit
66-
//basket_exit_crash();
67-
basket_exit();
68-
69-
}
70-
7165
Do not use the phpdoc on every function, eg
7266

7367
/**
@@ -77,25 +71,15 @@ Do not use the phpdoc on every function, eg
7771
*/
7872
>>
7973
function login($user, $pass){
80-
.......
74+
8175
}
8276
<<
83-
as this function explains its self, the following clean code will suffice
77+
as this function is self-explaining, the following clean code will suffice
8478
>>
8579
function login($user, $pass){
86-
.......
80+
8781
}
8882

89-
If you do need to explain a function then put un the summary syntax eg
90-
91-
/** Pass an array of values where third param is bar
92-
* $foo['bar'] = 1; // allow a user
93-
* $foo['bar'] = 2; // destroy user
94-
* $foo['bar'] = -1; // recreate
95-
*/
96-
public function do_something($x, $y, $foo){
97-
... do something interesting
98-
}
9983

10084
//*****************************************************************************
10185
// Where to store custom settings

0 commit comments

Comments
 (0)