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

Bug #19892 ELSE with no braces causes incorrect SWITCH break statement indentation error
Submitted: 2013-04-10 17:02 UTC
From: sanjayr Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.4.5)
PHP Version: 5.3.3 OS: Linux Fedora core 12
Roadmaps: (Not assigned)    
Subscription  


 [2013-04-10 17:02 UTC] sanjayr (Sanjay Rakholiya)
Description: ------------ - Please check Test Script code sample. - Switch case break statement already indent properly with 8 space in case 'A' - Its give error message, ERROR | Case breaking statement indented incorrectly; expected 8 spaces found 12 - Working properly for case 'B' Test script: --------------- <?php switch($case_name) { case 'A': if($cond_a == 1) return 1; else return 0; break; case 'B': if($cond_b == 1) { return 1; } else { return 0; } break; } Expected result: ---------------- Its shouldn't return error on case 'A'.

Comments

 [2013-04-12 06:10 UTC] squiz (Greg Sherwood)
-Summary: Incorrect error massage on Switch Case breaking statement indented incorrec +Summary: ELSE with no braces causes incorrect SWITCH break statement indentation error -Assigned To: +Assigned To: squiz
 [2013-04-12 06:11 UTC] squiz (Greg Sherwood)
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/c275359a3f4f9ebc09b8b7cfe69 e79052ddf3ec6 This was caused by the ELSE statement having to braces inside the first CASE. PHPCS was using the "return 0" as the breaking statement on the CASE statement, which is obviously incorrect.
 [2013-04-12 06:12 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed