PSR-2 prevents the use of readability best practices

210 views
Skip to first unread message

Rafael Dohms

unread,
Apr 3, 2013, 9:26:53 AM4/3/13
to php-f...@googlegroups.com

Hey guys,

I was wondering if i could get some eye on this issue: https://github.com/php-fig/fig-standards/issues/102

I know this is a recommended practice used by some of us and some of the participating projects.

I'll replicate it here to get some discussion on it:

Noticed this in the new PHPCS Version since a fix was made to follow the NO SPACE rule after opening parenthesis in control structures.
This goes against a very common best practice in code readability, that states you should add whitespace around !negation operators to highlight them against the rest of the condition, avoiding mistakes based on lack of attention.
With rule There MUST NOT be a space after the opening parenthesis this now becomes a violation. I would suggest an exception be added that allows the space it its part of a whitespace buffer around (both sides) of a operator.
Basically we would allow if ( ! $var) { instead of just if (!$var) {.
There is a lot of material on this in the The Art of Readable Code by O'Reilly.
Can we make this addition?

Thanks 

Paul Jones

unread,
Apr 3, 2013, 9:38:51 AM4/3/13
to Rafael Dohms, php-f...@googlegroups.com
No. Martin Bean is correct in the thread.


-- pmj

Rafael Dohms

unread,
Apr 3, 2013, 9:43:48 AM4/3/13
to php-f...@googlegroups.com, Rafael Dohms
Paul,

Care to go into details? I hardly think "don't implement it if you don't like" is response, maybe i missed the actual response.

I'm just thinking that PSR-2 should not prevent Best Practices for fear of it being ignored by even more project and hence becoming a useless standard. 
Is that not a valid point?

Paul Jones

unread,
Apr 3, 2013, 9:47:30 AM4/3/13
to Rafael Dohms, php-f...@googlegroups.com

On Apr 3, 2013, at 8:43 AM, Rafael Dohms wrote:

> Paul,
>
> Care to go into details? I hardly think "don't implement it if you don't like" is response, maybe i missed the actual response.
>
> I'm just thinking that PSR-2 should not prevent Best Practices for fear of it being ignored by even more project and hence becoming a useless standard.
> Is that not a valid point?

Not in this case. And to be clear, it's not "best practices" plural. It's a singluar recommendation that you happen to be paying attention to.


-- pmj

Rafael Dohms

unread,
Apr 3, 2013, 10:00:33 AM4/3/13
to php-f...@googlegroups.com, Rafael Dohms
First of a few, but a starting point.

That's ok, if that is the evaluation i'll just remove PSR-2 from my recommendations and stick to PSR-1 + readability practices. 
If it does not do the group any good then no use pushing it.

Thanks.
 

-- pmj

Andrew Eddie

unread,
Apr 3, 2013, 11:32:38 PM4/3/13
to php-f...@googlegroups.com, Rafael Dohms
On Thursday, 4 April 2013 00:00:33 UTC+10, Rafael Dohms wrote:
That's ok, if that is the evaluation i'll just remove PSR-2 from my recommendations and stick to PSR-1 + readability practices. 
If it does not do the group any good then no use pushing it.

PSR-2 is just "a" line in the sand. At the end of the day you are going to have other layers of rules where PSR-2 is silent so just use it as a base and where you don't agree with it, change your requirements (that's what I've done).

Regards,
Andrew Eddie 
Reply all
Reply to author
Forward
0 new messages