[PSR-12] blank line after <?php

105 views
Skip to first unread message

mcf...@gmail.com

unread,
Dec 8, 2017, 10:59:32 PM12/8/17
to PHP Framework Interoperability Group
Hi everyone

I just found that whether there should be one blank line  after opening `<?php` is not clarified now. also examples in current standard are not consistent. there is some statement about `<?php`, but I think the number of blank line after that should also be standardized

current statement:

When the opening <?php tag is on the first line of the file, it MUST be on its own line with no other statements unless it is a file containing markup outside of PHP opening and closing tags.


Woody Gilk

unread,
Dec 9, 2017, 12:26:34 AM12/9/17
to PHP Framework Interoperability Group
The current de facto standard is that `declare` statements immediately follow the `<?php` tag:

<?php
declare(strict_types=1);

namespace Acme;

Or when there is no `declare` statement:

<?php

namespace Acme;

This should probably be codified into PSR-12.

--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscribe@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/b905d5c7-a3ac-45c3-8d9f-87947d4cfe65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adrien Crivelli

unread,
Dec 10, 2017, 1:32:28 AM12/10/17
to PHP Framework Interoperability Group
I agree that it has to be standardized and not left open to interpretation. And since all other header blocks are treated the same way, it make sense to also treat `<?php` the same way and don't make an exception for `declare` statement.

I submitted a pull request for that: https://github.com/php-fig/fig-standards/pull/984
Reply all
Reply to author
Forward
0 new messages