From 0a78e95fe20cfd1fe1e6f9d000758c3903494b56 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 26 May 2016 12:02:04 +0200 Subject: [PATCH 1/3] Updated the CS rule about return null; and return; --- contributing/code/standards.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 4acceb31a05..fdbde53d41d 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -91,7 +91,7 @@ example containing most features described below: ); if (true === $dummy) { - return; + return null; } if ('string' === $dummy) { @@ -114,7 +114,7 @@ example containing most features described below: private function reverseBoolean($value = null, $theSwitch = false) { if (!$theSwitch) { - return; + return null; } return !$value; @@ -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); * Use braces to indicate control structure body regardless of the number of statements it contains; From cf3b9ab32cca170c7f2765a01af6104d971474a4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 20 Jun 2016 11:48:58 +0200 Subject: [PATCH 2/3] Added a "void" return example --- contributing/code/standards.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index fdbde53d41d..025a66758d3 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -109,12 +109,12 @@ 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) { if (!$theSwitch) { - return null; + return; } return !$value; From 874024be5a22de6c0a3f607283d40cc2d24baef0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 21 Jun 2016 15:30:51 +0200 Subject: [PATCH 3/3] Removed the mention to PHP 7.1 --- contributing/code/standards.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 025a66758d3..0891db1067e 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -144,8 +144,7 @@ Structure inside a statement-group (like an ``if`` statement); * Use ``return null;`` when a function explicitly returns ``null`` values and - use ``return;`` when the function returns ``void`` values (available from - PHP 7.1); + use ``return;`` when the function returns ``void`` values; * Use braces to indicate control structure body regardless of the number of statements it contains;