Skip to content

Commit ef8ac39

Browse files
authored
Generic/OpeningFunctionBraceKernighanRitchie: improve XML documentation (#927)
* Generic/OpeningFunctionBraceKernighanRitchie: fix syntax errors in the XML doc code examples * Generic/OpeningFunctionBraceKernighanRitchie: improve XML doc - `<documentation>` title matches the sniff name. - Don't mention the Kernighan/Ritchie style in the `<standard>` description as according to Wikipedia this style uses the opening brace for functions on a separate line and not on the same line (https://en .wikipedia.org/wiki/Indentation_style#K&R). - I believe it is more precise to say that the sniff checks if the opening brace is on the same line as the closing parenthesis and not the function declaration as the function declaration can be multi-line. - Mention in the `<standard>` description that there must be no content on the line after the opening brace. - Improve the title of the `<code>` blocks.
1 parent f281e46 commit ef8ac39

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
<documentation title="Opening Brace in Function Declarations">
1+
<documentation title="Opening Function Brace Kerninghan Ritchie">
22
<standard>
33
<![CDATA[
4-
Function declarations follow the "Kernighan/Ritchie style". The function brace is on the same line as the function declaration. One space is required between the closing parenthesis and the brace.
4+
The function opening brace must be on the same line as the end of the function declaration, with
5+
exactly one space between the end of the declaration and the brace. The brace must be the last
6+
content on the line.
57
]]>
68
</standard>
79
<code_comparison>
8-
<code title="Valid: Brace on same line.">
10+
<code title="Valid: Opening brace on the same line.">
911
<![CDATA[
1012
function fooFunction($arg1, $arg2 = '')<em> {</em>
11-
...
13+
// Do something.
1214
}
1315
]]>
1416
</code>
15-
<code title="Invalid: Brace on next line.">
17+
<code title="Invalid: Opening brace on the next line.">
1618
<![CDATA[
1719
function fooFunction($arg1, $arg2 = '')
1820
<em>{</em>
19-
...
21+
// Do something.
2022
}
2123
]]>
2224
</code>

0 commit comments

Comments
 (0)