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

Bug #20047 Undefined index: scope_closer, T_CASE and return
Submitted: 2013-08-22 18:55 UTC
From: herve_ms Assigned:
Status: Duplicate Package: PHP_CodeSniffer (version 1.5.0RC3)
PHP Version: 5.4.18 OS: Linux Cent OS
Roadmaps: (Not assigned)    
Subscription  


 [2013-08-22 18:55 UTC] herve_ms (Herve Seignole)
Description: ------------ We have a notice "Undefined index: scope_closer", when we use case with return. For exemple, in Zend Framework 1 (library/Zend/XmlRpc/Value.php). Other remark, here, the case self::CASE1 is decomposed in : T_CASE T_WHITESPACE T_SELF T_DOUBLE_COLON T_GOTO_LABEL. But, here, it's not a T_GOTO_LABEL ! Test script: --------------- <?php class A { const CASE1 = 'A'; const CASE2 = 'B'; const CASE3 = 'C'; public function bug() { $type = 'A'; switch ($type) { case self::CASE1: return 1; case self::CASE2: case self::CASE3: return 0; } } } Expected result: ---------------- -------------------------------------------------------------------------------- FOUND 5 ERROR(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 3 | ERROR | Missing class doc comment 9 | ERROR | Missing function doc comment 15 | ERROR | Line indented incorrectly; expected 8 spaces, found 12 19 | ERROR | Line indented incorrectly; expected 8 spaces, found 12 -------------------------------------------------------------------------------- Actual result: -------------- Notice: Undefined index: scope_closer in /usr/local/etc/httpd/lib/php/PHP/CodeSniffer/Tokenizers/PHP.php on line 667 ...

Comments

 [2013-08-23 06:08 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Duplicate
I just merged a PR to fix this issue. It was also reported on bug #20051 and the fix is listed there. I'll mark this as a duplicate for reporting purposes, even though it was submitted before the other one.