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

Bug #18847 Running Squiz_Sniffs_Classes_ClassDeclarationSniff results in PHP notice
Submitted: 2011-09-20 02:23 UTC
From: mikumakues Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0)
PHP Version: 5.3.6 OS: Kubuntu 11.04
Roadmaps: (Not assigned)    

 [2011-09-20 02:23 UTC] mikumakues (Michael Kues)
Description: ------------ If you run Squiz_Sniffs_Classes_ClassDeclarationSnif on any file, you get the following php notice: Undefined variable: nextComma in /usr/share/php/PHP/CodeSniffer/Standards/Squiz/Sniffs/Classes/ p on line 240. The fix could be to declare $nextComma and set it to 0 just outside the for loop on line 232 (for ($i = 0; $i < $parentCount; $i++) {)


 [2011-09-22 07:33 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
Can you please provide me with some sample code to replicate this error. The only way I can get that code to run before nextComma is set is to create a class declaration with syntax errors, like: class ClassOne implements ,ClassTwo,ClassThree If you can show me the class declaration causing the issue, I'd like to add the structure into the unit test for the sniff so I can be sure it is fixed and stays fixed.
 [2011-09-29 02:12 UTC] mikumakues (Michael Kues)
Hi Greg, Sorry for the late answer. First of all a correction on my side is due: it's not on any file (of course it's not!). Mea culpa. After some research I could replicate the notification with the bare class declaration below. Strangely enough there is no comma in the class declaration. By the way: thanks for the wonderful tool that PHP_CodeSniffer is! <?php namespace Aem\Auth\Storage; /** * File storage. */ class File implements \Zend_Auth_Storage_Interface { }
 [2011-10-07 07:03 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Thanks a lot for getting back to me with the sample code. That helped nail down where the assumption was in the code.