Skip to content

Updated the CS rule about return null; and return; #6614

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

Closed
wants to merge 3 commits into from
Closed
Changes from 2 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
9 changes: 5 additions & 4 deletions contributing/code/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ example containing most features described below:
);

if (true === $dummy) {
return;
return null;
}

if ('string' === $dummy) {
Expand All @@ -109,7 +109,7 @@ example containing most features described below:
* @param mixed $value Some value to check against
* @param bool $theSwitch Some switch to control the method's flow
*
* @return bool|null The resultant check if $theSwitch isn't false, null otherwise
* @return bool|void The resultant check if $theSwitch isn't false, void otherwise
*/
private function reverseBoolean($value = null, $theSwitch = false)
{
Expand Down Expand Up @@ -143,8 +143,9 @@ Structure
* Add a blank line before ``return`` statements, unless the return is alone
inside a statement-group (like an ``if`` statement);

* Use just ``return;`` instead of ``return null;`` when a function must return
void early;
* Use ``return null;`` when a function explicitly returns ``null`` values and
use ``return;`` when the function returns ``void`` values (available from
PHP 7.1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if the last part wouldn't be confusing. Could people think that this isn't usable yet as their code needed to be compatible with older PHP versions too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I indeed think the part between parenthesis can be removed as it doesn't add anything really usefull (and removing it avoids confusion)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been removed. Thanks!


* Use braces to indicate control structure body regardless of the number of
statements it contains;
Expand Down