Skip to content

[RFC] Clarification on formatting for bangs (!) #4457

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 10 commits into from

Conversation

bryanagee
Copy link
Contributor

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, 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.

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.
@wouterj
Copy link
Member

wouterj commented Nov 13, 2014

-1, it isn't done in the Symfony standard, so it shouldn't belong here. /cc @fabpot

@xabbuh
Copy link
Member

xabbuh commented Nov 13, 2014

👎 for the same reasons

@stof
Copy link
Member

stof commented Nov 13, 2014

Symfony does not put spaces around ! (the Symfony rule would be the opposite actually)

@bryanagee
Copy link
Contributor Author

That makes sense. I will submit a pull request with the opposite
clarification.
On Nov 13, 2014 4:48 AM, "Christophe Coevoet" [email protected]
wrote:

Symfony does not put spaces around ! (the Symfony rule would be the
opposite actually)


Reply to this email directly or view it on GitHub
#4457 (comment).

@bryanagee
Copy link
Contributor Author

Alright; as discussed, I have added a clarification to the opposite affect.

@@ -86,7 +94,10 @@ Structure

* Add a single space after each comma delimiter;

* Add a single space around operators (``==``, ``&&``, ...);
* Add a single space around operators (``==``, ``&&``, ...), with the excption
Copy link
Member

Choose a reason for hiding this comment

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

exception

@xabbuh
Copy link
Member

xabbuh commented Nov 13, 2014

I'm still not sure if it is really necessary to add this clarification. Let's see what the others think.

@bryanagee
Copy link
Contributor Author

@xabbuh Thanks--I corrected the errors you mentioned.

Personally, I think the clarification is worth while as it would save folks like me some time. All the well-organized projects I had worked on until recently have had the bang spacing, and the current wording would seem to say that is the right way.

The only reason I discovered the discrepancy was my having another pull request to a symfony-based project critiqued on that front, and reading a more specific coding standard would have saved me the trouble of having to go back through and adjust them all.

if (!isset($value)) {
return;
}
return !$value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing empty line above return

@stof
Copy link
Member

stof commented Nov 13, 2014

the right way to say it would be Add a space around binary operators (except the concatenation). the sentence here does not apply to any of the unary operators (!, ++, --)

@bryanagee
Copy link
Contributor Author

@stof: I modified the language as you suggested. What do you think?


private function reverseBoolean($value = null)
{
if (!isset($value)) {
Copy link
Member

Choose a reason for hiding this comment

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

$value is always set. So this is a redundant check. if (!$value) would be against the CS, so I propose to add another switch which defaults to false or the like to do something else and then use if (!$theSwitch)

Copy link
Member

Choose a reason for hiding this comment

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

indeed, we never use !isset($value) to check for null, but null === $value

@@ -86,7 +95,10 @@ Structure

* Add a single space after each comma delimiter;

* Add a single space around operators (``==``, ``&&``, ...);
* Add a single space around binary operators (``==``, ``&&``, ...), with
the exception of the concatenation (``,``) operator;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a period? Or am I mis-understanding this?

@weaverryan
Copy link
Member

@stof This looks sensible to me, but I'd like to have your +1 on it before I merge.

@stof
Copy link
Member

stof commented Dec 2, 2014

👍

@weaverryan
Copy link
Member

Thanks Bryan for the conversation and PR :). Cheers!

weaverryan added a commit that referenced this pull request Dec 6, 2014
…gee)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #4457).

Discussion
----------

[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.

Commits
-------

ee888c6 Fixes concat operator typo
33e76a5 Incorporates @wouterj 's suggestion for more realistic usage of bang
837e895 Changes operator spacing language
835d5eb Adds missing space before return statement
3799bc0 Fixes spelling and formatting errors
30d19ab Fixes wrong bullet character
3212b6c Adds bullet addressing bang placement
95a1cc5 Reverses statement about bang spacing and corresponding examples
a68d3e5 [RFC] Clarification on formatting for bangs (!)
@weaverryan weaverryan closed this Dec 6, 2014
jmontoyaa referenced this pull request in chamilo/chamilo-lms Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants