Skip to content

Commit 7219eae

Browse files
committed
Add the documentation for the PSR12 Return Type Declaration sniff
1 parent 2ab648b commit 7219eae

File tree

1 file changed

+39
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)