squizlabs / PHP_CodeSniffer

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

readonly class: Expected 0 spaces before class keyword; 1 found #3947

Closed steevanb closed 3 months ago

steevanb commented 3 months ago

Describe the bug

When a class is readonly, ClassDeclaration sniff report Expected 0 spaces before class keyword; 1 found.

I know it's fixed on master (https://github.com/squizlabs/PHP_CodeSniffer/commit/3f7b9ba8544073fb2ff7c879c70d036090ebd95a), but i don't see any final version with this fix.

Could you please create 3.7.3?

Code sample

readonly class Foo
{
}

To reproduce

   9  [x] Expected 0 spaces before class keyword; 1 found
   |       |     (Squiz.Classes.ClassDeclaration.SpaceBeforeKeyword)

Expected behavior

No error ;)

Versions (please complete the following information)

Operating System [Windows 10 with WSL2 (tested on Debian and Ubutun 22.04)]
PHP version [8.3.4]
PHP_CodeSniffer version [3.7.2]
Standard [Squiz.Classes.ClassDeclaration.SpaceBeforeKeyword]
Install type [Composer global]

Please confirm:

fredden commented 3 months ago

@steevanb please have a look at https://github.com/squizlabs/PHP_CodeSniffer/issues/3932. If still relevant, please open a new issue in the new repository. The latest version of PHP_CodeSniffer is 3.9.1. From what I can tell, this change was released as part of 3.8.0.

jrfnl commented 3 months ago

@steevanb Please upgrade to the latest PHPCS version and your problem is gone. You are using version 3.7.2, while the latest PHPCS version is 3.9.1.

Closing as invalid.