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

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)    
Subscription  


 [2014-04-20 15:27 UTC] aik099 (Alexander Obuhovich)
Description: ------------ I think the following code https://github.com/squizlabs/PHP_CodeSniffer/blob/1.5.2/CodeSn 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

Comments

 [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: https://github.com/squizlabs/PHP_CodeSniffer/commit/8345e9d6dd5c6e4666d19a66d 50d9ed3e9cc5114
 [2014-05-05 17:10 UTC] aik099 (Alexander Obuhovich)
Here you go: https://github.com/aik099/CodingStandard/blob/master/CodingStandard/Sniffs/White Space/ControlStructureSpacingSniff.php I guess it will pass your tests if you set "requiredSpacesAfterOpen" and "requiredSpacesBeforeClose" to 0.