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
Copy file name to clipboardexpand all lines: source/coding_standards/php.rst
+14-12
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Arrays must be declared using the short notation syntax (``[]``), long notation
9
9
Including files
10
10
---------------
11
11
12
-
Use ``include_once`` in order to include the file once and to raise warning if file does not exists:
12
+
Use ``include_once`` in order to include the file once and to raise warning if file does not exist:
13
13
14
14
.. code-block:: php
15
15
@@ -31,7 +31,7 @@ The PHP closing tag ``?>`` must be avoided on full PHP files (so in most of GLPI
31
31
Functions
32
32
---------
33
33
34
-
Function names must be written in *camelCaps*:
34
+
Function names must be written in *camelCase*:
35
35
36
36
.. code-block:: php
37
37
@@ -40,9 +40,9 @@ Function names must be written in *camelCaps*:
40
40
//do something here!
41
41
}
42
42
43
-
Space after opening parenthesis and before closing parenthesis are forbidden. For parematers which have a default value; add a space before and after the equel sign.
43
+
Space after opening parenthesis and before closing parenthesis are forbidden. For parameters which have a default value, add a space before and after the equals sign.
44
44
45
-
If parameters add block doc for these parameters, please see the `Comments`_ section for any example.
45
+
If the function has parameters, add doc block for these parameters. Please see the `Comments`_ section for an example.
46
46
47
47
If function from parent add
48
48
@@ -51,7 +51,7 @@ If function from parent add
51
51
<?php
52
52
function getMenuContent()
53
53
54
-
If it's a new function, add in block doc (see the `Comments`_ section):
54
+
If it's a new function, add the `@since` tag in the doc block (see the `Comments`_ section):
55
55
56
56
.. code-block:: php
57
57
@@ -96,9 +96,9 @@ On the other hand; if you already have an object instance; you should better use
96
96
Classes
97
97
-------
98
98
99
-
Class names must be written in `CamelCase`:
99
+
Class names must be written in *PascalCase*:
100
100
101
-
GLPI do not use `PHP namespaces <http://php.net/manual/en/language.namespaces.php>`_ right now; so be careful when creating new classes to take a name that does not exists yet.
101
+
Most of the GLPI code does not use or support `PHP namespaces <http://php.net/manual/en/language.namespaces.php>`_ yet. Therefore, you will need to be careful when creating new classes to take a name that does not exists yet.
102
102
103
103
.. code-block:: php
104
104
@@ -108,9 +108,9 @@ GLPI do not use `PHP namespaces <http://php.net/manual/en/language.namespaces.ph
108
108
}
109
109
110
110
111
-
Note: even if GLPI does not use namespaces, some libs does, you will have to take care of that. You can also if you wish use namespaces for PHP objects call.
111
+
Note: You can use namespaces for PHP classes if you want, but you should be aware that there are some parts of the code that still don't support them. As a good rule, avoid using a namespaced class to extend CommonDBTM.
112
112
113
-
For example, the folloging code:
113
+
For example, the following code:
114
114
115
115
.. code-block:: php
116
116
@@ -137,6 +137,8 @@ Could also be written as (see the ``\``):
137
137
...
138
138
}
139
139
140
+
When referring to classes in another namespace you SHOULD use `use` statements instead of using the full name.
141
+
140
142
Comments
141
143
--------
142
144
@@ -170,9 +172,9 @@ For each method or function documentation, you'll need at least to have a descri
170
172
//[...]
171
173
}
172
174
173
-
Some other informations way be added; if the function requires it.
175
+
Some other information may be added if the function requires it.
174
176
175
-
Refer to the `PHPDocumentor website <https://phpdoc.org/docs/latest>`_ to get more informations on documentation. The `latest GLPI API documentation <https://forge.glpi-project.org/projects/glpi/embedded/index.html>`_ is also available online.
177
+
Refer to the `PHPDocumentor website <https://phpdoc.org/docs/latest>`_ to get more information on documentation. The `latest GLPI API documentation <https://forge.glpi-project.org/projects/glpi/embedded/index.html>`_ is also available online.
176
178
177
179
Please follow the order defined below:
178
180
@@ -193,7 +195,7 @@ Parameters documentation
193
195
Each parameter must be documented in its own line, begining with the ``@param`` tag, followed by the `Variables types`_, followed by the param name (``$param``), and finally with the description itself.
194
196
If your parameter can be of different types, you can list them separated with a ``|`` or you can use the ``mixed`` type; it's up to you!
195
197
196
-
All parameters names and description must be aligned vertically on the longest (plu one character); see the above example.
198
+
All parameters names and description must be aligned vertically on the longest (plus one character); see the above example.
197
199
198
200
Override method: @inheritDoc? @see? docblock? no docblock?
0 commit comments