From 3978e2620ea3ad50f80bc273542ff9dc830743fd Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 29 Apr 2012 19:07:48 +0100 Subject: [ticket/10855] Modified coding guidelines to reflect JS brace changes. Braces always go on the same line in JavaScript. PHPBB3-10855 --- phpBB/docs/coding-guidelines.html | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'phpBB/docs') diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 3f2c142ac6..fbec59a6ff 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -397,7 +397,7 @@ for ($i = 0; $i < size; $i++)

Where to put the braces:

-

This one is a bit of a holy war, but we're going to use a style that can be summed up in one sentence: Braces always go on their own line. The closing brace should also always be at the same column as the corresponding opening brace, examples:

+

In PHP code, braces always go on their own line. The closing brace should also always be at the same column as the corresponding opening brace, examples:

 if (condition)
@@ -427,6 +427,30 @@ function do_stuff()
 	...
 }
 	
+ +

In JavaScript code, braces always go on the same line:

+ +
+if (condition) {
+	while (condition2) {
+		...
+	}
+} else {
+	...
+}
+
+for (var i = 0; i < size; i++) {
+	...
+}
+
+while (condition) {
+	...
+}
+
+function do_stuff() {
+	...
+}
+	

Use spaces between tokens:

This is another simple, easy step that helps keep code readable without much effort. Whenever you write an assignment, expression, etc.. Always leave one space between the tokens. Basically, write code as if it was English. Put spaces between variable names and operators. Don't put spaces just after an opening bracket or before a closing bracket. Don't put spaces just before a comma or a semicolon. This is best shown with a few examples, examples:

-- cgit v1.2.1