PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

`Squiz.WhiteSpace.MemberVarSpacing` can only fix property with attribute preceded by a comment

Open pattisahusiwa opened this issue 2 years ago • 1 comments

Describe the bug Currently, phpcs can only fix a property with attribute preceded by a comment.

Code sample

<?php

final class MemberVar
{
    // phpcs can fix this but not the next one
    #[SingleAttribute]

    public $property1;
    #[SingleAttribute]

    public $property2;

    #[SingleAttribute]

    public $property3;
}

Custom ruleset

<?xml version="1.0"?>
<ruleset name="My Custom Standard">
  <rule ref="Squiz.WhiteSpace.MemberVarSpacing" />
</ruleset>

To reproduce Steps to reproduce the behavior:

  1. Create a file called test.php with the code sample above...
  2. Run phpcs test.php ...

Expected behavior The result should be something like this

<?php

final class MemberVar
{
    // phpcs can fix this but not the next one
    #[SingleAttribute]
    public $property1;

    #[SingleAttribute]
    public $property2;

    #[SingleAttribute]
    public $property3;
}

Versions (please complete the following information):

  • OS: Arch Linux
  • PHP: 8.1
  • PHPCS: 3.6.2
  • Standard: Squiz

pattisahusiwa avatar May 16 '22 23:05 pattisahusiwa

Related #3334, #3419, #3440

jrfnl avatar May 17 '22 00:05 jrfnl