In PSR-12, what are lines 255 and 256 actually referring to?

80 views
Skip to first unread message

Shawn Corrigan

unread,
Nov 29, 2021, 1:16:32 PM11/29/21
to PHP Framework Interoperability Group
Hi everyone,

I tried to find an answer to this in the existing conversations here but I couldn't seem to find anything, I apologize if it's already been discussed.

I'm reading PSR-12 and trying to understand what these two lines mean. They seem to be disconnected from the subsection they're in, so it's hard to tell what it's referring to exactly.

Lines 255 and 256 are under subsection 4.1 -  Extends and Implements. They are also under section 4 - Classes, Properties, and Methods.

They say...

> Opening braces MUST be on their own line and MUST NOT be preceded or followed by a blank line
> Closing braces MUST be on their own line and MUST NOT be preceded by a blank line.

There are no opening or closing braces directly associated with the "extends" or "implements" keywords, just for the class.

Above that, in the same section, it says “The opening brace for the class MUST […]”. That line explicitly specifies the brace is for the class, but the two lines in question don't specify what the braces are for.

Are those lines referring to the class, just as the line above it is? Or is it referring to the section title; Classes, Properties, and Methods? (leaving out properties).

Korvin Szanto

unread,
Nov 29, 2021, 6:24:51 PM11/29/21
to php...@googlegroups.com
Hi Shawn,
You can trust the section header, those lines are referring to style when dealing with implements and extends. 

The reason we are so verbose in this spot is partly because some of this is left verbatim from PSR-2 as we added around it and partly because we want to be sure we cover all bases when dealing with single line vs multi-line class declaration lines.

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/ef016517-32bd-4f83-9ad6-443d8e5c2244n%40googlegroups.com.

Shawn Corrigan

unread,
Nov 30, 2021, 10:06:11 AM11/30/21
to PHP Framework Interoperability Group
Thanks for the response!

So to be clear, the lines are referencing the class? I guess there was just some ambiguity based on how braces can refer to the implements and extends keyword, it could make sense to add "for the class" to those lines as well to be consistent with the line above, although I'm not sure what it looks like to change that.

Unrelated, is it completely allowed with PSR-12 to have additional blank lines following opening braces in methods?

Reply all
Reply to author
Forward
0 new messages