Skip to content

[Documentation] PSR12 - Return Type Declaration #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<documentation title="Return Type Declaration">
<standard>
<![CDATA[
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.

The colon and the return type declaration have to be on the same line as the argument list closing parenthesis.
]]>
</standard>
<code_comparison>
<code title="Valid: A single space between the colon and type in a return type declaration.">
<![CDATA[
$closure = function ( $arg ):<em> </em>string {
// Closure body.
};
]]>
</code>
<code title="Invalid: No space between the colon and the type in a return type declaration.">
<![CDATA[
$closure = function ( $arg ):<em></em>string {
// Closure body.
};
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: No space before the colon in a return type declaration.">
<![CDATA[
function someFunction( $arg )<em></em>: string {
// Function body.
};
]]>
</code>
<code title="Invalid: One or more spaces before the colon in a return type declaration.">
<![CDATA[
function someFunction( $arg )<em> </em>: string {
// Function body.
};
]]>
</code>
</code_comparison>
</documentation>