Skip to content

Commit da43b73

Browse files
dingo-djrfnl
authored andcommitted
Add the documentation for the PSR12 Return Type Declaration sniff
1 parent 1703a6b commit da43b73

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<documentation title="Return Type Declaration">
2+
<standard>
3+
<![CDATA[
4+
For function and closure return type declarations, there must be one space after the colon followed by the type declaration, and no space before the colon.
5+
6+
The colon and the return type declaration have to be on the same line as the argument list closing parenthesis.
7+
]]>
8+
</standard>
9+
<code_comparison>
10+
<code title="Valid: A single space between the colon and type in a return type declaration.">
11+
<![CDATA[
12+
$closure = function ( $arg ):<em> </em>string {
13+
// Closure body.
14+
};
15+
]]>
16+
</code>
17+
<code title="Invalid: No space between the colon and the type in a return type declaration.">
18+
<![CDATA[
19+
$closure = function ( $arg ):<em></em>string {
20+
// Closure body.
21+
};
22+
]]>
23+
</code>
24+
</code_comparison>
25+
<code_comparison>
26+
<code title="Valid: No space before the colon in a return type declaration.">
27+
<![CDATA[
28+
function someFunction( $arg )<em></em>: string {
29+
// Function body.
30+
};
31+
]]>
32+
</code>
33+
<code title="Invalid: One or more spaces before the colon in a return type declaration.">
34+
<![CDATA[
35+
function someFunction( $arg )<em> </em>: string {
36+
// Function body.
37+
};
38+
]]>
39+
</code>
40+
</code_comparison>
41+
</documentation>

0 commit comments

Comments
 (0)