PHP_CodeSniffer
PHP_CodeSniffer copied to clipboard
`Squiz.WhiteSpace.MemberVarSpacing` can only fix property with attribute preceded by a comment
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:
- Create a file called
test.php
with the code sample above... - 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
Related #3334, #3419, #3440