mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-06 07:35:29 +02:00
[ticket/10855] Modified coding guidelines to reflect JS brace changes.
Braces always go on the same line in JavaScript. PHPBB3-10855
This commit is contained in:
parent
2a92fee06d
commit
3978e2620e
@ -397,7 +397,7 @@ for ($i = 0; $i < size; $i++)
|
||||
</pre></div>
|
||||
|
||||
<h4>Where to put the braces:</h4>
|
||||
<p>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:</p>
|
||||
<p>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:</p>
|
||||
|
||||
<div class="codebox"><pre>
|
||||
if (condition)
|
||||
@ -427,6 +427,30 @@ function do_stuff()
|
||||
...
|
||||
}
|
||||
</pre></div>
|
||||
|
||||
<p>In JavaScript code, braces always go on the same line:</p>
|
||||
|
||||
<div class="codebox"><pre>
|
||||
if (condition) {
|
||||
while (condition2) {
|
||||
...
|
||||
}
|
||||
} else {
|
||||
...
|
||||
}
|
||||
|
||||
for (var i = 0; i < size; i++) {
|
||||
...
|
||||
}
|
||||
|
||||
while (condition) {
|
||||
...
|
||||
}
|
||||
|
||||
function do_stuff() {
|
||||
...
|
||||
}
|
||||
</pre></div>
|
||||
|
||||
<h4>Use spaces between tokens:</h4>
|
||||
<p>This is another simple, easy step that helps keep code readable without much effort. Whenever you write an assignment, expression, etc.. Always leave <em>one</em> 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:</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user