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
<p>The contents of the Joomla! Coding Standards Manual are subject to copyright law and are made available under the <ahref="http://docs.joomla.org/JEDL"
For new contributions we are going to be enforcing coding standards to ensure that the coding style in the source code is consistent. Ensuring that your code meets these standards will make the process of code contribution smoother.
4
4
5
-
In order to improve the consistency and readability of the source code,
6
-
we run a coding style analysis tool everytime changes are pushed in the
7
-
repo. For new contributions we are going to be enforcing coding
8
-
standards to ensure that the coding style in the source code is
9
-
consistent. Ensuring that your code meets these standards will make the
10
-
process of code contribution smoother.
5
+
## Configuring Code Analysis Tools
11
6
12
-
The Joomla Platform sniffer rules are written to be used with a tool
13
-
called PHP\_CodeSniffer. Please see the [PHP\_CodeSniffer Pear
7
+
In order to improve the consistency and readability of the source code, the Joomla project runs a coding style analysis tool, CodeSniffer, everytime changes are pushed to a Joomla project's repository.
8
+
9
+
### Running CodeSniffer
10
+
11
+
The Joomla Coding Standards sniffer rules are written to be used with a tool called PHP CodeSniffer. Please see the [PHP CodeSniffer Pear
14
12
Page](http://pear.php.net/package/PHP_CodeSniffer) for information on
15
-
installing PHP\_CodeSniffer on your system.
13
+
installing PHP CodeSniffer on your system.
16
14
17
-
##### Running CodeSniffer
15
+
You can run the CodeSniffer by going to the CMS, Framework, or Issue Tracker's root directory and executing
18
16
19
-
You can run the CodeSniffer by going to the platform root directory and
Alternatively, if you have Ant installed on your system, you may run the
24
-
CodeSniffer by going to the platform root directory and executing
25
-
`ant phpcs`
21
+
Alternatively, if you have Ant installed on your system, you may run the CodeSniffer by going to the `<root directory>` of the Joomla project's code you want to test and executing
26
22
27
-
##### Known Issues
23
+
```
24
+
ant phpcs
25
+
```
26
+
27
+
#### Known Issues
28
28
29
29
- There is currently an issue with running the Code Sniffer on the
30
30
Simplepie library. Pointing the sniffs at the libraries/joomla
31
31
directory or below will avoid the issue.
32
32
33
+
## Other Tools
34
+
35
+
Here are some other tools available to developers who are planning to submit source code to the project.
Copy file name to clipboardExpand all lines: manual/en-US/coding-standards/chapters/basic-guidelines.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,28 @@
1
1
## Basic Guidelines
2
2
3
-
This chapter outlines the basic guidelines that cover and files.
3
+
This chapter outlines the basic guidelines covering files contributed to the Joomla project. The most important rule to remember when coding for the Joomla project, **if in doubt, please ask**.
4
4
5
-
## File Format
5
+
###File Format
6
6
7
-
All files contributed to Joomla must be stored as ASCII text, use UTF-8 character encoding and be Unix formatted. Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.
7
+
All files contributed to Joomla must be:
8
8
9
-
## Spelling
9
+
* Stored as ASCII text
10
+
* Use UTF-8 character encoding
11
+
* Be Unix formatted following these rules.
12
+
1. Lines must end only with a line feed (LF).
13
+
2. Line feeds are represented as ordinal 10, octal 012 and hex 0A.
14
+
3. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.
10
15
11
-
The spelling of words and terms used in code comments and in the naming of class, functions, variables and constant should generally be in accordance with British English rules (en\_GB). However, some exceptions are permitted, for example where common programming names are used that align with the PHP API or other established conventions such as for “color” where is it common practice to maintain US English spelling.
16
+
### Spelling
12
17
13
-
## Indenting
18
+
The spelling of words and terms used in code comments and in the naming of class, functions, variables and constant should generally be in accordance with British English rules (en\_GB).
19
+
Some exceptions are permitted, for example where common programming names are used that align with the PHP API or other established conventions such as for `color` where is it common practice to maintain US English spelling.
20
+
21
+
### Indenting
14
22
15
23
Tabs are used for indenting code (not spaces as required by the PEAR standard). Source code editors or Integrated Development Environments (IDE’s) such as Eclipse must have the tab-stops for indenting measuring four (4) spaces in length.
16
24
17
-
## Line Length
25
+
###Line Length
18
26
19
27
There is no maximum limit for line lengths in files, however, a notional value of about 150 characters is recommended to achieve a good level of readability without horizontal scrolling. Longer lines are permitted if the nature of the code for individual lines requires it and line breaks would have an adverse affect on the final output (such as for mixed PHP/HTML layout files).
Copy file name to clipboardExpand all lines: manual/en-US/coding-standards/chapters/inline-comments.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
-
## Comments
1
+
## Inline Code Comments
2
2
3
-
This chapter covers inline commenting in more detail. Inline comments are all comments not included in doc blocs. The goal of in line commenting is to explain code in context. Such explanation may take many different forms.
3
+
This chapter covers inline code commenting in more detail. Inline comments are all comments not included in doc blocs. The goal of in line commenting is to explain code in context. Such explanation may take many different forms.
4
4
5
5
Comments that are written in a readable and narrative style, especially when explaining a complex process, are encouraged. In general they should be placed close to the code explained rather than before the entire block of code.
6
6
7
7
Comments should be as sentence like as possible, which is to say that they should be complete and readable, not in short hand.
8
8
9
9
Comments are not a replacement for detailed doc blocks. Comments serve to explain the logic and structure of code itself rather than the use of code.
10
10
11
-
## Formatting of Comments
11
+
###Formatting of Comments
12
12
13
13
Comment blocks that introduce large sections of code and are more than 2 lines long should use `/* */` (C) style and should use `*` on each line with the same space/tab rules as doc blocks. If you need a large introduction consider whether this block should be separated into a method to reduce complexity and therefore providing a full docblock.
14
14
@@ -22,7 +22,7 @@ Comments should align with the code they refer to, using the same indenting as t
22
22
23
23
Comments should be indented with tabs (like code, not like doc blocks).
24
24
25
-
## Content of comments
25
+
###Content of comments
26
26
27
27
Comments should use en-GB (See below).
28
28
@@ -46,23 +46,23 @@ Comments may include forward looking statements of how something will be extende
46
46
47
47
Remember that humor and sarcasm are difficult to translate.
48
48
49
-
## Acronyms
49
+
###Acronyms
50
50
51
51
Capitalise all letters of acronyms such as HTML, XML, SQL, GMT, and UTC. This is an exception to the general use of en-GB rules.
52
52
53
-
## Common spelling and grammar errors for which to check.
53
+
###Common spelling and grammar errors for which to check.
54
54
55
55
Joomla contributors include many non-native speakers of en-GB which makes it understandable that there are sometimes spelling and grammar errors. At the same time, some people reading comments also are non native speakers and may even use automated translation to understand comments. This makes it very important that comments should follow proper en-GB spelling and grammar rules. Unfortunately, these can be tricky.
56
56
57
-
Wikipedia provides a good summary of common differences between en-US and en-GB. http://en.wikipedia.org/wiki/American\_and\_British\_English\_spelling\_differences Note that there are some instances where en-GB common usage (but not actual rules) varies slightly from en-AU and using en-AU is considered acceptable.
57
+
Wikipedia provides a good summary of [common differences between en-US and en-GB](http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences). Note that there are some instances where en-GB common usage (but not actual rules) varies slightly from en-AU and using en-AU is considered acceptable.
58
58
59
-
### S vs Z
59
+
####S vs Z
60
60
61
61
en-GB most commonly uses `ise` where en-US would use `ize`, such as `normalise` instead of `normalize`. (Note that there are some exceptions to this rule and some differences between en-GB and en-AU in common usage.)
62
62
63
63
Use of apostrophes is one of the trickier parts of English.
64
64
65
-
### Lets versus let’s
65
+
####Lets versus let’s
66
66
67
67
Lets means permits or allows to:
68
68
@@ -76,7 +76,7 @@ Let’s is a contraction for let us and means we are going to do this now:
76
76
// Let's validate the field
77
77
```
78
78
79
-
### Its versus it’s
79
+
####Its versus it’s
80
80
81
81
Its is the possessive form of it:
82
82
@@ -90,8 +90,8 @@ It’s is a contraction of it is
90
90
// It's time to save
91
91
```
92
92
93
-
### The correct Joomla spelling of some commonly used words.
94
-
95
-
- Dependant
93
+
#### The correct Joomla spelling of some commonly used words.
Copy file name to clipboardExpand all lines: manual/en-US/coding-standards/chapters/php.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,8 @@ For example, do not include feature submissions like:
173
173
//$code = broken($fixme);
174
174
```
175
175
176
+
More details on inline code comments can be found in the chapter on [Inline Code Comments](coding-standards/chapters/inline-comments.md).
177
+
176
178
### Comment Docblocks
177
179
178
180
Documentation headers for PHP and Javascript code in files, classes, class properties, methods and functions, called the docblocks, follow a convention similar to JavaDoc or phpDOC.
0 commit comments