Add rule for PHP 8 promotion constructor in PSR-12?

1,393 views
Skip to first unread message

Dr. Adam Nielsen

unread,
Dec 15, 2021, 9:32:40 AM12/15/21
to PHP Framework Interoperability Group
Hello,

I wanted to request an exception rule for PSR-12.

Currently there is this rule:

> Method and function names MUST NOT be declared with space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body.  [...] When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them.
 
This means, if you want to use PHP 8 constructor property promotion with PSR-12 it looks like this:

class User { 
  public function __construct( 
          private Service $service 
  ){
  }
 } 

which I think looks broken. Could we add a rule that opening and closing brace can be on the same line when used for constructor and if body is empty?

So it would be ok to look like this:

class User { 
  public function __construct( 
          private Service $service 
  ){}
 } 

?

Alessandro Lai

unread,
Dec 15, 2021, 9:34:55 AM12/15/21
to PHP Framework Interoperability Group
Hello and welcome!
PSR-12 is unfortunately not up to date with the latest shiny stuff that we got with PHP 8+. We recently approved the PER workflow, so we could try to migrate PSR-12 to a PER, and make it easier to update.

Anyone willing to help on this?

Alex Makarov

unread,
Dec 15, 2021, 9:46:15 AM12/15/21
to php...@googlegroups.com
What's needed to do it? A list of new shiny stuff and rules for it?
Could be done. What else?
> --
> 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/3a674fc4-37af-4a1d-af68-f9debccb996an%40googlegroups.com.

Larry Garfield

unread,
Dec 15, 2021, 9:53:27 AM12/15/21
to PHP-FIG
On Wed, Dec 15, 2021, at 8:45 AM, Alex Makarov wrote:
> What's needed to do it? A list of new shiny stuff and rules for it?
> Could be done. What else?
>
> On Wed, Dec 15, 2021 at 5:34 PM Alessandro Lai
> <alessand...@gmail.com> wrote:
>>
>> Hello and welcome!
>> PSR-12 is unfortunately not up to date with the latest shiny stuff that we got with PHP 8+. We recently approved the PER workflow, so we could try to migrate PSR-12 to a PER, and make it easier to update.
>>
>> Anyone willing to help on this?

Process wise, here's how it should happen:

* A new working group gets together and petitions the CC to get recognized for a "coding standards" per. I am going to request that it be a full-size group (5 member including CC Sponsor) not a mini-group, given its importance.

* The first thing the new WG does is copy-paste PSR-12 to a new doc and release it as CodingStandards v1. (Or maybe we can get away with tagging it v2? Either/or.) The exact process for that is noted in the byalws, and will require another CC vote.

* Once that's done, the WG can start debating/accepting PRs for coding standards updates; when there's "enough" (as defined by the Editor), they can release either a 1.1 or a 2.0 (or 2.1/3.0), with the exact process again noted in the bylaws. This MAY require a CC vote, depending on how the CC feels about it. Again, all explained in the bylaws.

I would encourage the Editor to be someone who was involved in PSR-12, but beyond that it's the same "anyone interested and dedicated" as any other WG.

--Larry Garfield

Navarr Barnier

unread,
Dec 15, 2021, 11:18:12 AM12/15/21
to PHP Framework Interoperability Group
For reference, the PSR-12 WG was:
  • Korvin Szanto
  • Chris Tankersley
  • Alessandro Lai
  • Alexander Makarov
  • Michael Cullum
  • Robert Deutz
Korvin has already stated they don't have the availability/energy to be the editor.  Alessandro said they needed to ask Santa, but as a Secretary they can't be an editor iirc.  

Is there anyone that's willing to step up to be editor of this?

Alex Makarov

unread,
Dec 15, 2021, 3:43:23 PM12/15/21
to php...@googlegroups.com
I can be part of the group. If there will be a lack of editor role, I
can handle it.
> --
> 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/1fd118b6-d80f-480d-b033-a22d79b9d0c6%40www.fastmail.com.

Korvin Szanto

unread,
Dec 15, 2021, 9:21:30 PM12/15/21
to php...@googlegroups.com
I don't plan to lead this through the PER process but I'd be happy to be on the WG under your leadership Alex.


Woody Gilk

unread,
Dec 16, 2021, 9:20:31 AM12/16/21
to PHP Framework Interoperability Group
I am willing to be part of this WG.


Alessandro Lai

unread,
Dec 22, 2021, 4:39:55 AM12/22/21
to PHP Framework Interoperability Group
I'm happy to be part of the WG too, if you want me :D

Ralf Lang

unread,
Dec 25, 2021, 2:57:54 AM12/25/21
to php...@googlegroups.com
Willing to help but I am not sure yet I understand how a PER works. I am very interested in all the new features 8.1 offers and how one would best render them to legible code that fits in with all the other guidelines. So count me in.

--
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.

Alessandro Lai

unread,
Jan 5, 2022, 12:24:55 PM1/5/22
to PHP Framework Interoperability Group
Ok great! I'm trying to kick this off, with the help of Alex which offered to be the editor. Anyone interested, you can join us on Discord on the dedicated #per-coding-style channel: https://discord.gg/x3q64aD5BE

Woody, Ralf, you two in particular, since I couldn't find you there already :D
Reply all
Reply to author
Forward
0 new messages