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

Bug #20051 Undefined index: scope_opener / scope_closer
Submitted: 2013-08-22 21:51 UTC
From: vipsoft Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.3.10 OS: Ubuntu 10.04
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 : 19 + 27 = ?

 
 [2013-08-22 21:51 UTC] vipsoft (Anthon Pang)
Description: ------------ Branch: report-memory-improvements Hash: bbf881a Two or more "case SomeClass::SOMECONST" statements consecutively causes multiple notices in PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php. (The notices are different from the one reported in bug #20047.) Also false positive "CASE statements must not be defined using curly braces" (PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase) . (See https://github.com/robocoder/PHP_CodeSniffer/issues/1 if the test script below gets malformed.) Test script: --------------- <?php namespace Test; /** * Foo */ class Foo { const ONE = 1; const TWO = 2; /** * foo * * @param mixed $bar */ public function foo($bar) { switch ($bar) { case Foo::ONE: case Foo::TWO: break; } } } Expected result: ---------------- No errors. Actual result: -------------- PHP Notice: Undefined index: scope_opener in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 109 Notice: Undefined index: scope_opener in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 109 PHP Notice: Undefined index: in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 110 Notice: Undefined index: in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 110 PHP Notice: Undefined index: scope_closer in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 120 Notice: Undefined index: scope_closer in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 120 PHP Notice: Undefined index: in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 121 Notice: Undefined index: in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 121 PHP Notice: Undefined index: scope_opener in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 138 Notice: Undefined index: scope_opener in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 138 PHP Notice: Undefined index: scope_opener in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 147 Notice: Undefined index: scope_opener in /var/www/application/vendor/squizlabs/php_codesniffer/Code Sniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclar ationSniff.php on line 147 FILE: /tmp/Foo.php ------------------------------------------------------------------------ -------- FOUND 2 ERROR(S) AFFECTING 2 LINE(S) ------------------------------------------------------------------------ -------- 20 | ERROR | CASE statements must not be defined using curly braces | | (PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase) 21 | ERROR | CASE statements must not be defined using curly braces | | (PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase) ------------------------------------------------------------------------ -------- Time: 0 seconds, Memory: 6.25Mb

Comments

 [2013-08-22 23:02 UTC] vipsoft (Anthon Pang)
I'm testing a fix and will submit a PR after I write a test.
 [2013-08-23 06:02 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/6c162f3050458798acacf1685d dc453a91a9fdb3 Thanks a lot for the patch.