From 7077a54b65fc3483f99fa1a0090a8dfb4b16ff85 Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Wed, 12 Nov 2014 21:04:50 -0800 Subject: [PATCH 1/9] [RFC] Clarification on formatting for bangs (!) It seems to me that > Add a single space around operators would mean using the practice on the bang operator as well; as discussed in [this thread](https://github.com/php-fig/fig-standards/issues/102), there is somewhat of a conflict--so this may not be the way to go. If the PSR could be amended, then this change would make sense. --- contributing/code/standards.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index a2720e991df..448d818ad36 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -79,6 +79,14 @@ example containing most features described below: throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy)); } + + private function reverseBoolean($value = null) + { + if ( ! isset($value)) { + return; + } + return ! $value; + } } Structure @@ -86,7 +94,7 @@ Structure * Add a single space after each comma delimiter; -* Add a single space around operators (``==``, ``&&``, ...); +* Add a single space around operators (``==``, ``&&``, ``!``, ...); * Add a comma after each array item in a multi-line array, even after the last one; From bb51e3bfc4b59b514aab090c9afc2ba368403c0e Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Thu, 13 Nov 2014 09:13:51 -0800 Subject: [PATCH 2/9] Reverses statement about bang spacing and corresponding examples --- contributing/code/standards.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 448d818ad36..206eb076f3e 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -82,10 +82,10 @@ example containing most features described below: private function reverseBoolean($value = null) { - if ( ! isset($value)) { + if (!isset($value)) { return; } - return ! $value; + return !$value; } } @@ -94,7 +94,8 @@ Structure * Add a single space after each comma delimiter; -* Add a single space around operators (``==``, ``&&``, ``!``, ...); +* Add a single space around operators (``==``, ``&&``, ...), with the excption + of the not (!) operator; * Add a comma after each array item in a multi-line array, even after the last one; From 75c4fc217f3cc1d0e02d035a46fe04de99fcb5e8 Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Thu, 13 Nov 2014 09:15:50 -0800 Subject: [PATCH 3/9] Adds bullet addressing bang placement --- contributing/code/standards.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 206eb076f3e..9e2c58396ce 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -97,6 +97,8 @@ Structure * Add a single space around operators (``==``, ``&&``, ...), with the excption of the not (!) operator; ++ Place the not operator adjacent to the variable that it affects + * Add a comma after each array item in a multi-line array, even after the last one; From 9736b15595cfe9164707ec19631f2562bd8eea4e Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Thu, 13 Nov 2014 09:16:52 -0800 Subject: [PATCH 4/9] Fixes wrong bullet character --- contributing/code/standards.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 9e2c58396ce..110892d6dda 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -97,7 +97,7 @@ Structure * Add a single space around operators (``==``, ``&&``, ...), with the excption of the not (!) operator; -+ Place the not operator adjacent to the variable that it affects +* Place the not operator adjacent to the variable that it affects * Add a comma after each array item in a multi-line array, even after the last one; From 119d94e68dd814c5c5d00939180d74596dad7b29 Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Thu, 13 Nov 2014 11:46:46 -0800 Subject: [PATCH 5/9] Fixes spelling and formatting errors --- contributing/code/standards.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 110892d6dda..5964832034e 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -94,10 +94,10 @@ Structure * Add a single space after each comma delimiter; -* Add a single space around operators (``==``, ``&&``, ...), with the excption - of the not (!) operator; +* Add a single space around operators (``==``, ``&&``, ...), with the + exception of the not (``!``) operator; -* Place the not operator adjacent to the variable that it affects +* Place the not operator adjacent to the variable that it affects; * Add a comma after each array item in a multi-line array, even after the last one; From 87279d2cd4f940f759037882a5b8490da36c3e08 Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Thu, 13 Nov 2014 13:51:16 -0800 Subject: [PATCH 6/9] Adds missing space before return statement --- contributing/code/standards.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 5964832034e..23998ea0965 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -85,6 +85,7 @@ example containing most features described below: if (!isset($value)) { return; } + return !$value; } } From c2fa7db41f38c5518048b8e65a8c2fd564b98869 Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Thu, 13 Nov 2014 13:51:48 -0800 Subject: [PATCH 7/9] Changes operator spacing language --- contributing/code/standards.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 23998ea0965..f09a2aff1d3 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -95,10 +95,10 @@ Structure * Add a single space after each comma delimiter; -* Add a single space around operators (``==``, ``&&``, ...), with the - exception of the not (``!``) operator; +* Add a single space around binary operators (``==``, ``&&``, ...), with + the exception of the concatenation (``,``) operator; -* Place the not operator adjacent to the variable that it affects; +* Place unary operators (``!``, ``--``, ...) adjacent to the affected variable; * Add a comma after each array item in a multi-line array, even after the last one; From de4c018938df6add0dbdda0e419dfb8d698d8aa4 Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Fri, 14 Nov 2014 10:01:38 -0800 Subject: [PATCH 8/9] Incorporates @WouterJ 's suggestion for more realistic usage of bang --- 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 f09a2aff1d3..23fedc1f6f1 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -80,9 +80,9 @@ example containing most features described below: throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy)); } - private function reverseBoolean($value = null) + private function reverseBoolean($value = null, $theSwitch = false) { - if (!isset($value)) { + if (!$theSwitch) { return; } From d7949fd8e2f1db5f44de4a127b3a6b311a09a88c Mon Sep 17 00:00:00 2001 From: "Bryan J. Agee" Date: Mon, 24 Nov 2014 10:59:04 -0800 Subject: [PATCH 9/9] Fixes concat operator typo --- contributing/code/standards.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/code/standards.rst b/contributing/code/standards.rst index 23fedc1f6f1..1fb4297ddce 100644 --- a/contributing/code/standards.rst +++ b/contributing/code/standards.rst @@ -96,7 +96,7 @@ Structure * Add a single space after each comma delimiter; * Add a single space around binary operators (``==``, ``&&``, ...), with - the exception of the concatenation (``,``) operator; + the exception of the concatenation (``.``) operator; * Place unary operators (``!``, ``--``, ...) adjacent to the affected variable;