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.

+3


source to share


2 answers


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:



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 .

+1


source


Ok, which looks better? It:

namespace Foo;
use Bar\Baz;
use Bar\Qux;
function test()
{
}

      

Or that:



namespace Foo;

use Bar\Baz;
use Bar\Qux;

function test()
{
}

      

I think he speaks for himself.

+5


source







All Articles