• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PHPCSStandards / PHP_CodeSniffer / 13848627330

14 Mar 2025 02:29AM UTC coverage: 77.518% (+0.004%) from 77.514%
13848627330

push

github

jrfnl
Squiz/ClassDeclaration: allow for function attributes

The `Squiz.Classes.ClassDeclaration` sniff checks the number of blank lines _after_ a class closing brace to be exactly one blank line.

To prevent conflicts with other sniffs checking blank lines before function declarations, it bows out when the next thing after the class declaration is a function declaration and defers to the function declaration sniff to handle the "blank lines before function" check.
See squizlabs/PHP_CodeSniffer 2033 for historic context.

However, the above "bowing out" breaks when a function after a class has PHP 8.0+ attributes attached to it and the sniff would still the `NewlinesAfterCloseBrace` error.

Fixed now.

Includes tests.

Note: the new "errors" caused by the new tests are for the `MultipleClasses` code, which is unrelated to this fix and valid.

13 of 13 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

19295 of 24891 relevant lines covered (77.52%)

76.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.06
/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc