[PSR-12] Additional Thoughts from an outsider

104 views
Skip to first unread message

Mark Baker

unread,
Sep 29, 2018, 6:28:29 PM9/29/18
to php...@googlegroups.com

Just as an outsider looking at PSR-12 (Extended Coding Style Guide) with a couple of suggestions:

Namespace separators

There shouldn't be any whitespace around a namespace separator, wherever it is used. PHP permits this, but it can be less inutive to read

Increment/Decrement Operators

There shouldn't be any whitespace between the increment/decrement operators, ad the variable being incremented/decremented. This can cause difficulty reading code, especially where the arithmetic plus/minus operators as used within the same expression.

$a ++ + ++ $a

I've not seen reference to either of these cases in the style PSRs

-- 
Mark Baker

 _________
|.  \     \-3
|_J_/ PHP |
|| |  __  |
|| |m|  |m|

 I LOVE PHP

Alessandro Lai

unread,
Oct 8, 2018, 4:27:29 PM10/8/18
to PHP Framework Interoperability Group
Thank you for you suggestions!
For the first one, I've never seen in the wild an usage that would contradict that rule, have you ever?
As for the second, it seems pretty reasonable to me, and I've just created a PR: https://github.com/php-fig/fig-standards/pull/1089

Mark Baker

unread,
Oct 10, 2018, 2:07:53 AM10/10/18
to php...@googlegroups.com
On 08/10/2018 21:27, Alessandro Lai wrote:
> Thank you for you suggestions!
I've not yet seen it in the wild, and hadn't even realised that it was
possible until it was pointed out to me, though it's probably only a
matter of time before somebody decides that whitespace there is good...
of course (as has also been pointed out to me) very long namespaces
might need to span multiple lines, so a newline followed by 4 spaces
indentation is possible.... although I'm not convinced that namespaces
should be that long

> For the first one, I've never seen in the wild an usage that would
> contradict that rule, have you ever?
> As for the second, it seems pretty reasonable to me, and I've just
> created a PR: https://github.com/php-fig/fig-standards/pull/1089


Thanks. that whitespace regularly appears in the occasional PHP WTF that
some people are inclined to post every so often, deliberately
obfuscating; so it's goo dto provide clarity within the coding standards
PSR.
Reply all
Reply to author
Forward
0 new messages