PHP: PSR-2: Why blank lines after the namespace / use declarations?
So the other day I was going over the PSR coding standards (which I duly adhere to) and I always understood the reasons behind everything and basically coded this way for everything that I have worked on for the last 10 years, very similar standards have been heavily imposed on me in my university days - she just got stuck.
However, I do think about this PSR-2 note :
There should be one blank line after the namespace declaration and there should be one blank line after the block usage declaration.
Why is this? I don't mind this, but I'm sure there is some background or story to explain and it never jumped out of me like why. I guess the obvious reason is legibility, but I have a feeling there are deeper reasons for this standard.
While I'm at it - does anyone know of any good resources to explain the logic behind all PSR guidelines? It's helpful to have formal reasoning and a story that has led to certain standards, trying to convince others to follow them, who may not be convinced of their own interests.
source to share
I think the best resource you are going to get is the PHP-FIG mailing list, specifically the archive on Google Groups. Here are some interesting discussions related to your question:
- Who voted and how for the coding standard
- The "final" version when placed in the "php-standards" group (later renamed FIG) . Note that this thread has a dead link pointing to where the document was used when the group was named "php standards".
- From this thread , you can follow this blog post from Travis Swicegood which gives me the clearest indication of the source: PEAR2.
My personal recollection is that the standard emerged as a mixture of the PEAR2, PHPCS, Doctrine1 and Flow3 styles. But it was all 5 years ago, and I forgot all about it .
source to share