PSR-2 repeatedly mentions "blank lines" that MUST or MAY be put in certain positions (e.g. a blank line is required after a namespace declaration). But it never defines what is meant by a blank line - is a blank line a line with only whitespace characters on it, or must it contain only a newline character?
If I'm working with indented code (say in a class definition or something), my blank lines will contain spaces up to the same indentation level as the surrounding code, although they will appear blank. Is this acceptable? Is there any preference one way or the other?
Hi,On Thu, Sep 27, 2012 at 4:07 PM, Patrick Mulvey <pdmu...@gmail.com> wrote:PSR-2 repeatedly mentions "blank lines" that MUST or MAY be put in certain positions (e.g. a blank line is required after a namespace declaration). But it never defines what is meant by a blank line - is a blank line a line with only whitespace characters on it, or must it contain only a newline character?
PSR-2 at section "2.3 Lines" says:
"There MUST NOT be trailing whitespace at the end of non-blank lines."
i.e. it does not make any point about trailing whitespace on blank lines. So I guess whatever you do should be fine according to the standard.
If I'm working with indented code (say in a class definition or something), my blank lines will contain spaces up to the same indentation level as the surrounding code, although they will appear blank. Is this acceptable? Is there any preference one way or the other?
--
Si no puedes deslumbrar con tu sabiduría,
desconcierta con tus gilipolleces
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
On Thursday, September 27, 2012 at 7:18 AM, Sebastian Krebs wrote:
PSR-2 at section "2.3 Lines" says:
"There MUST NOT be trailing whitespace at the end of non-blank lines."
i.e. it does not make any point about trailing whitespace on blank lines. So I guess whatever you do should be fine according to the standard.
Can anybody explain my, why there is this restriction to non-blank lines only?
"There MUST NOT be trailing whitespace at the end of non-blank lines."
i.e. it does not make any point about trailing whitespace on blank lines. So I guess whatever you do should be fine according to the standard.
Can anybody explain my, why there is this restriction to non-blank lines only?
PSR-1/2 do this sort of thing in several places. They explicitly leave room open for variation where there are different preferences and no clear advantage either way.
PSR-1/2 do this sort of thing in several places. They explicitly leave room open for variation where there are different preferences and no clear advantage either way.
I have to disagree with that. It isn't explicit at all. To me it is an undefined term, and it's hard to judge the intent of the author based on that.
The term "blank line" has no formal definition - my idea of a blank line may conflict with yours, or the author's. Section 7 of PSR-2 lists some elements of style which are intentionally not mentioned by the document - blank lines are not one of them. So we end up with this vague term appearing repeatedly throughout the document, which may be interpreted in different ways by different people. This leads to the possibility of conflicting expectations and implementations - i.e. the very thing these standards are trying to avoid.To "explicitly" leave it open for variation, you have to actually say it's open for variation, not just omit any mention of it from the document. Explicitly leaving it open would be saying something like "A blank line is one with no visible characters on it. It may optionally include whitespace characters, e.g. for matching code indentation". As it is, it's undefined, which is a source of uncertainty.
It's worth noting that what constitutes a blank line has already spawned some confusion and disagreement.Because of this, I think it would be helpful to add a glossary of terms to the PSRs, to clarify potentially ambiguous language.
On Thursday, September 27, 2012 3:45:43 PM UTC+1, Justin Hileman wrote:On Thursday, September 27, 2012 at 7:18 AM, Sebastian Krebs wrote:
2012/9/27 Carlos Campderrós <gilipollas.d...@gmail.com>
PSR-2 at section "2.3 Lines" says:
"There MUST NOT be trailing whitespace at the end of non-blank lines."
i.e. it does not make any point about trailing whitespace on blank lines. So I guess whatever you do should be fine according to the standard.
Can anybody explain my, why there is this restriction to non-blank lines only?Because some people like to keep blank lines indented to the level of the surrounding text.PSR-1/2 do this sort of thing in several places. They explicitly leave room open for variation where there are different preferences and no clear advantage either way.-- j
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/sJeN84kEg4YJ.
To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/lIAL_y1WydYJ.
To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/jgKHOSaZe1AJ.
Hope this helps, please let me know if it does not.
/me goes back to drinking his manhattan
-- pmj
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
--j
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To post to this group, send email to php...@googlegroups.com.
To unsubscribe from this group, send email to php-fig+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
"A blank line is any line composed only of zero or more spaces followed by a newline."
(Spaces, not tabs, as PSR-2 specifies spaces for indentation.)
As noted previously in this thread, some developers prefer to have indented blank lines between indented non-blank lines, so that when scrolling down, the cursor doesn't jump left and right. Similarly, some editors, when indenting a block of lines, will indent otherwise blank lines as well. But some would have the lines with no spaces in them at all. PSR-2 makes no recommendation either way.
I would argue that the rule saying "All PHP files MUST end with a single blank line" is a special case of blankness, meaning "the last character is a single newline not preceded by any other whitespace."
Yes, it's inconsistent; happy to hear about terminology that would resolve it. Similarly, happy to hear other variations of the definition so we can come to an agreement on the proper terminology.