PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
990 stars 60 forks source link

PSR2.Classes.PropertyDeclaration.Multiple throws false positives when value is a variable #257

Closed tvdijen closed 10 months ago

tvdijen commented 10 months ago

Describe the bug

PSR2.Classes.PropertyDeclaration.Multiple throws false positives when the default value is a variable.

Code sample

use Some\Other\Class as C;

class A
{
    public static array $SUPPORTED_SIGNATURE_ALGORITHMS = C::$RSA_DIGESTS;
}

PHPCS output here

Expected behavior

I expect the test to pass. Instead the following error is displayed: There must not be more than one property declared per statement (PSR2.Classes.PropertyDeclaration.Multiple)

Versions (please complete the following information)

Operating System [CentOS 9]
PHP version [8.1]
PHP_CodeSniffer version [3.8.1]
Standard [PSR12]
Install type [Composer]

Additional context

Add any other context about the problem here.

Please confirm:

jrfnl commented 10 months ago

@tvdijen Eh... that's because that is not valid PHP.... ? https://3v4l.org/KeO3Z

Sorry, but sniffs should not have to deal with fantasy code which isn't supported by PHP itself.

tvdijen commented 10 months ago

You are right, I don't know what I was thinking.