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.66k stars 1.48k forks source link

PSR2/ClassDeclaration: bug fix - blank line fixer also removes indent #3846

Closed jrfnl closed 9 months ago

jrfnl commented 1 year ago

Description

The PSR2.Classes.ClassDeclaration.CloseBraceAfterBody related logic checks that there is no blank line between the last content within the class and the close brace.

The fixer for this error code, however, does not take indented class declarations into account and inadvertently also removes (correct) indentation.

Fixed now. Includes unit test.

Suggested changelog entry

The PSR2.Classes.ClassDeclaration.CloseBraceAfterBody fixer will no longer remove potential indentation before the close brace.

Types of changes

jrfnl commented 9 months ago

Closing as replaced by https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/65

jrfnl commented 8 months ago

FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).