Skip to content

PSR-12 is in ithe making of creating a style guide for attributes #3688

Closed

Description

@snake-py

Hello,

today I noticed that code sniffer (with psr-12) will throw an error by code like this:

#[AsCommand(name: 'serveDebug')]
class ServeDebug extends ServeCommand

because the current rule seems not to take into account that one line above a class definition can be attributed the output:

FILE: /app/Console/Commands/ServeDebug.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Header blocks must be separated by a single blank
   |       |     line
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

I know that they have not totally settled on a style php-fig/per-coding-style#26

I just wanted to raise awareness, because I am guessing the rule should be changed for php 8 users. I don't see that they will settle on an required additional line between the attribute and the class.

Activity

  1. jrfnl commented on May 7, 2023

    @jrfnl
    Contributor

    Related to #3793

  2. rodrigoprimo commented on Feb 25, 2026

    @rodrigoprimo

    I was not able to reproduce this problem on the latest version of PHPCS using the PSR12 standard. Here is the output that I got using a file with the code sample provided here:

    ❯ bin/phpcs --standard=PSR12 test.php                                                                                                                                                                                                                                                                            at 17:00:49 
    Time: 25ms; Memory: 6MB
    

    It seems to me this is a duplicate of #3286, which was closed as fixed. I believe that this issue can be closed.

  3. added this to the 3.6.0 milestone on Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions