PSR-2 Methods and Parenthesis Spacing With Negation

1,196 views
Skip to first unread message

Jesse O'Brien

unread,
Dec 30, 2012, 1:38:36 PM12/30/12
to php...@googlegroups.com
Hi,

I was discussing this today with a few people and wondering if there was any room for an exception to the "Must not be a space after the opening parenthesis" in PSR-2 for boolean negation ( ! ). 

The part I'm referring to is here:
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md#43-methods

What I'm proposing:
if (! is_array($array))
changes to
if ( ! is_array($array))
only when ! is involved.

The reasoning:
Based on the principles of grouping here, proximity of objects can lead to perceiving two close proximity objects as the same thing. I've had issues myself using certain fonts and IDE's where the "not" (! is missed because it's right beside the parenthesis and hard to see upon glancing over the code. This can really mess with logic when trying to grok someone else's code. I think what I'm proposing makes it easier to read and maintain for everyone.

Drak

unread,
Dec 30, 2012, 1:43:59 PM12/30/12
to php...@googlegroups.com
By 2 cents: I think things have moved on with the IDE, now syntax highlighting makes things very clear. It's not all black and white and the extra visual aides (colours) make visual proximity a non-issue.

Regards,

Drak


--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/cg-9qKaMljUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jesse O'Brien

unread,
Dec 30, 2012, 2:11:03 PM12/30/12
to php...@googlegroups.com
I do agree colours can make it easier. However if anyone out there is like me (and stats say 5% of males are) then being colourblind throws a negative factor into the syntax highlighting. Just as a thought on it.

Florin Patan

unread,
Dec 30, 2012, 2:23:27 PM12/30/12
to php...@googlegroups.com
Hey there, just my 2 cents here as well.

Assuming that you work with PSR2 formated code, then the syntax would be like this:

if (in_array())

and

if (! in_array())


So the simple presence of a space should be a good indicator of something more that just a simple statement there.
If you are not viewing a PSR2 code then you should format it first anyway, that's my habit at least.
As for the part when you quickly browse thru code I can't really say, I'm usually not that interested in every line unless it matches something that I think it should match in order to me to stop and read it more carefully. There are other options for color blind people as well like having a larger font, different font which better delimits the symbols and so on.


Best regards.

Michael C

unread,
Dec 30, 2012, 3:05:06 PM12/30/12
to php...@googlegroups.com

My 2 cents (we’ll be rich by the time everyone has given theirs) is that with syntax highlighting, easy to read fonts and the space after the ! it should be relatively easy to see. Some fonts might perhaps be harder to read (especially without syntax highlighting) but my suggestion to you would be to find an easier to use font or perhaps (if your editor supports it) make character spacing larger?

 

Thanks,

Michael Cullum

 

--

You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/z4TfULgxzFMJ.

Larry Garfield

unread,
Dec 30, 2012, 3:26:08 PM12/30/12
to php...@googlegroups.com
Didn't we vote to setup a new mailing list for this sort of discussion?  The vote passed.  I don't know if anyone ever set the list up, however...

--Larry Garfield

Handrus Nogueira

unread,
Jan 2, 2013, 3:00:03 PM1/2/13
to php...@googlegroups.com
You're right Larry.
By the end the motion passed, but nobody set up the group.

Lukas offered to do so, but he should be listed as a member before doing so... Still some voting member should create the group and update the page to state the group is the place to go.

Going to the point I don't think there is a exception.


2012/12/30 Larry Garfield <la...@garfieldtech.com>



--
Handrus Stephan Nogueira
Reply all
Reply to author
Forward
0 new messages