@@ -17,9 +17,7 @@ Indentation
17
17
18
18
One tab will be used for indentation.
19
19
20
- So, indentation should look like this:
21
-
22
- ::
20
+ So, indentation should look like this::
23
21
24
22
<?php
25
23
// base level
@@ -29,10 +27,9 @@ So, indentation should look like this:
29
27
// base level
30
28
?>
31
29
32
- Or:
33
-
34
- ::
30
+ Or::
35
31
32
+ <?php
36
33
$booleanVariable = true;
37
34
$stringVariable = "moose";
38
35
if ($booleanVariable) {
@@ -46,9 +43,7 @@ Control Structures
46
43
==================
47
44
48
45
Control structures are for example "``if ``", "``for ``", "``foreach ``",
49
- "``while ``", "``switch ``" etc. Below, an example with "``if ``":
50
-
51
- ::
46
+ "``while ``", "``switch ``" etc. Below, an example with "``if ``"::
52
47
53
48
<?php
54
49
if ((expr_1) || (expr_2)) {
@@ -58,7 +53,6 @@ Control structures are for example "``if``", "``for``", "``foreach``",
58
53
} else {
59
54
// default_action;
60
55
}
61
- ?>
62
56
63
57
* In the control structures there should be 1 (one) space before the
64
58
first parenthesis and 1 (one) space between the last parenthesis and
@@ -87,7 +81,6 @@ Control structures are for example "``if``", "``for``", "``foreach``",
87
81
if (expr) {
88
82
statement;
89
83
}
90
- ?>
91
84
92
85
Ternary Operator
93
86
----------------
@@ -96,10 +89,9 @@ Ternary operators are permissible when the entire ternary operation fits
96
89
on one line. Longer ternaries should be split into ``if else ``
97
90
statements. Ternary operators should not ever be nested. Optionally
98
91
parentheses can be used around the condition check of the ternary for
99
- clarity.
100
-
101
- ::
92
+ clarity::
102
93
94
+ <?php
103
95
//Good, simple and readable
104
96
$variable = isset($options['variable']) ? $options['variable'] : true;
105
97
@@ -111,23 +103,18 @@ Function Calls
111
103
112
104
Functions should be called without space between function's name and
113
105
starting bracket. There should be one space between every parameter of a
114
- function call.
115
-
116
- ::
106
+ function call::
117
107
118
108
<?php
119
109
$var = foo($bar, $bar2, $bar3);
120
- ?>
121
110
122
111
As you can see above there should be one space on both sides of equals
123
112
sign (=).
124
113
125
114
Method definition
126
115
=================
127
116
128
- Example of a function definition:
129
-
130
- ::
117
+ Example of a function definition::
131
118
132
119
<?php
133
120
function someFunction($arg1, $arg2 = '') {
@@ -136,19 +123,16 @@ Example of a function definition:
136
123
}
137
124
return $var;
138
125
}
139
- ?>
140
126
141
127
Parameters with a default value, should be placed last in function
142
128
definition. Try to make your functions return something, at least true
143
129
or false = so it can be determined whether the function call was
144
- successful.
145
-
146
- ::
130
+ successful::
147
131
148
132
<?php
149
- function connection(& $dns, $persistent = false) {
133
+ function connection($dns, $persistent = false) {
150
134
if (is_array($dns)) {
151
- $dnsInfo = & $dns;
135
+ $dnsInfo = $dns;
152
136
} else {
153
137
$dnsInfo = BD::parseDNS($dns);
154
138
}
@@ -158,7 +142,6 @@ successful.
158
142
}
159
143
return true;
160
144
}
161
- ?>
162
145
163
146
There are spaces on both side of the equals sign.
164
147
@@ -183,14 +166,9 @@ tags:
183
166
* `@since <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.since.pkg.html >`_
184
167
* `@tutorial <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.tutorial.pkg.html >`_
185
168
* `@version <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.version.pkg.html >`_
186
- * `inline {@internal}} <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlineinternal.pkg.html >`_
187
- * `inline {@inheritdoc}} <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html >`_
188
- * `inline {@link}} <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlinelink.pkg.html >`_
189
169
190
170
PhpDoc tags are very much like JavaDoc tags in Java. Tags are only
191
- processed if they are the first thing in a DocBlock line, for example:
192
-
193
- ::
171
+ processed if they are the first thing in a DocBlock line, for example::
194
172
195
173
<?php
196
174
/**
@@ -200,19 +178,13 @@ processed if they are the first thing in a DocBlock line, for example:
200
178
*/
201
179
?>
202
180
203
- There are 3 inline tags
204
- (`{@internal}} <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlineinternal.pkg.html >`_,
205
- `{@inheritdoc}} <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlineinheritdoc.pkg.html >`_
206
- and
207
- `{@link}} <http://manual.phpdoc.org/HTMLframesConverter/phpdoc.de/phpDocumentor/tutorial_tags.inlinelink.pkg.html >`_).
208
-
209
181
::
210
182
211
183
<?php
212
184
/**
213
185
* Example of inline phpDoc tags.
214
186
*
215
- * This function works hard with {@link foo()} to rule the world.
187
+ * This function works hard with foo() to rule the world.
216
188
*/
217
189
function bar() {
218
190
}
222
194
*/
223
195
function foo() {
224
196
}
225
- ?>
226
197
227
198
Comment blocks, with the exception of the first block in a file, should
228
199
always be preceeded by a newline.
@@ -244,26 +215,20 @@ Naming convention
244
215
Functions
245
216
---------
246
217
247
- Write all functions in camelBack
248
-
249
- ::
218
+ Write all functions in camelBack::
250
219
251
220
<?php
252
221
function longFunctionName() {
253
222
}
254
- ?>
255
223
256
224
Classes
257
225
-------
258
226
259
- Class names should be written in CamelCase, for example:
260
-
261
- ::
227
+ Class names should be written in CamelCase, for example::
262
228
263
229
<?php
264
230
class ExampleClass {
265
231
}
266
- ?>
267
232
268
233
Variables
269
234
---------
@@ -272,16 +237,13 @@ Variable names should be as descriptive as possible, but also as short
272
237
as possible. Normal variables should start with a lowercase letter, and
273
238
should be written in camelBack in case of multiple words. Variables
274
239
containing objects should start with a capital letter, and in some way
275
- associate to the class the variable is an object of. Example:
276
-
277
- ::
240
+ associate to the class the variable is an object of. Example::
278
241
279
242
<?php
280
243
$user = 'John';
281
244
$users = array('John', 'Hans', 'Arne');
282
245
283
246
$Dispatcher = new Dispatcher();
284
- ?>
285
247
286
248
Member visibility
287
249
-----------------
@@ -297,7 +259,6 @@ protected method or variable names start with a single underscore ("\_"). Exampl
297
259
/*...*/
298
260
}
299
261
}
300
- ?>
301
262
302
263
Private methods or variable names start with double underscore ("\_\_ "). Example::
303
264
@@ -309,12 +270,18 @@ Private methods or variable names start with double underscore ("\_\_"). Example
309
270
/*...*/
310
271
}
311
272
}
312
- ?>
313
273
314
274
Method Chaining
315
275
---------------
316
276
317
- todo
277
+ Method chaining should have multiple methods spread across separate lines, and
278
+ indented with one tab::
279
+
280
+ <?php
281
+
282
+
283
+ ->subject('A great message')
284
+ ->send();
318
285
319
286
Example addresses
320
287
-----------------
0 commit comments