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

Bug #19508 switch+return: Closing brace indented incorrectly
Submitted: 2012-07-12 14:19 UTC
From: cweiske Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.5)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 48 - 3 = ?

 
 [2012-07-12 14:19 UTC] cweiske (Christian Weiske)
Description: ------------ I get the following error when using a switch statement with a "return" in it: > Closing brace indented incorrectly; expected 0 spaces, found 4 This should not be. Test script: --------------- <?php switch ($foo) { case 1: return 1; } ?> Expected result: ---------------- No switch error Actual result: -------------- 4 | ERROR | Closing brace indented incorrectly; expected 0 spaces, found 4

Comments

 [2012-07-13 10:58 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
This was always banned and a unit test was written for it, but I think it was just a mistake. Recent changes to allow CASE statements to be ended with RETURN statements as well as BREAK statements have probably shown this up in some sniffs. Should now be fixed in github repo.
 [2012-07-18 03:03 UTC] bkendig (Brian Kendig)
I am seeing this bug in 1.3.5 even when I end the cases with breaks, like this: case 1: return 'one'; break; case 2: echo 'hello'; return 'two'; break; But it is fixed in the repo.