Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.1

Bug #20248 The Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff sniff and empty scope
Submitted: 2014-04-20 15:27 UTC
From: aik099 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.2)
PHP Version: 5.4.20 OS: Linux
Roadmaps: (Not assigned)    

 [2014-04-20 15:27 UTC] aik099 (Alexander Obuhovich)
Description: ------------ I think the following code iffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacing Sniff.php#L105-L135 must be wrapped with if ($firstContent !== $scopeCloser) { because right now for control structure that just have a blank line in them we have 2 errors: 1. blank line in the beginning of control structure 2. blank line in the end of control structure The "Generic.CodeAnalysis.EmptyStatement" will print more appropriate message for empty statements I think. Test script: --------------- if(something) { } // applies to all control structures


 [2014-04-29 10:57 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
I removed that second error message because it was redundant, but I'm not removing all errors for empty statements because there is no guarantee that your standard actually has the other sniff in it. That would be a fairly serious BC break. Commit is here: 50d9ed3e9cc5114
 [2014-05-05 17:10 UTC] aik099 (Alexander Obuhovich)
Here you go: Space/ControlStructureSpacingSniff.php I guess it will pass your tests if you set "requiredSpacesAfterOpen" and "requiredSpacesBeforeClose" to 0.