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

Bug #14575 PHP_Beautifier does not indent switch correctly
Submitted: 2008-08-27 20:03 UTC
From: ysangkok Assigned: clbustos
Status: Assigned Package: PHP_Beautifier (version 0.1.14)
PHP Version: 5.2.4 OS: GNU/Linux
Roadmaps: 1.0.0RC1    
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 : 38 - 4 = ?

 
 [2008-08-27 20:03 UTC] ysangkok (Janus Troelsen)
Description: ------------ When using PHP_Beautifier on this code, the indenting of the switch does not return to normal after the switch. Other switch code works fine, so maybe it has something to do with the fact that there is no "break", or that there is an if without brackets or "else". I extracted the code from a bigger script. PHP_Beautifier made all the code after that place indented with 4 spaces too many. This is the normal behaviour that I would expect: janus@Gigabob:21:55:20$ cat beautybug2.php <?php $v = 5; switch ($v) { case 5: exit; case 6: break; default: echo "hallo"; } ?> janus@Gigabob:21:58:32$ php_beautifier beautybug2.php <?php $v = 5; switch ($v) { case 5: exit; case 6: break; default: echo "hallo"; } ?> Test script: --------------- <?php define("dim", 3); define("blank", " "); $hexdigits = str_repeat(" ",100); function showno($no) { global $hexdigits; if ($no == blank) return '.'; switch (dim) { case 3: case 4: return $hexdigits[$no % 16]; // (custom modulo?) case 5: return $hexdigits[$no + 9]; case 6: if ($no < 11) return $hexdigits[$no % 10]; // (custom modulo?) if ($no > 10) return $hexdigits[$no - 1 ]; } return "_"; } echo showno(rand(0,100)); ?> Expected result: ---------------- <?php define("dim", 3); define("blank", " "); $hexdigits = str_repeat(" ", 100); function showno($no) { global $hexdigits; if ($no == blank) return '.'; switch (dim) { case 3: case 4: return $hexdigits[$no % 16]; // (custom modulo?) case 5: return $hexdigits[$no + 9]; case 6: if ($no < 11) return $hexdigits[$no % 10]; // (custom modulo?) if ($no > 10) return $hexdigits[$no - 1]; } return "_"; } echo showno(rand(0, 100)); ?> Actual result: -------------- <?php define("dim", 3); define("blank", " "); $hexdigits = str_repeat(" ", 100); function showno($no) { global $hexdigits; if ($no == blank) return '.'; switch (dim) { case 3: case 4: return $hexdigits[$no % 16]; // (custom modulo?) case 5: return $hexdigits[$no + 9]; case 6: if ($no < 11) return $hexdigits[$no % 10]; // (custom modulo?) if ($no > 10) return $hexdigits[$no - 1]; } return "_"; } echo showno(rand(0, 100)); ?>

Comments

 [2010-03-16 11:13 UTC] clbustos (Claudio Bustos)
-Assigned To: +Assigned To: clbustos -Roadmap Versions: +Roadmap Versions: 1.0.0RC1