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

Bug #17420 Uncaught exception when comment before function brace
Submitted: 2010-05-20 21:55 UTC
From: endi Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.2.2)
PHP Version: 5.3.2 OS: Debian Lenny (testing) x64
Roadmaps: (Not assigned)    

 [2010-05-20 21:55 UTC] endi (Andrea Azzini)
Description: ------------ PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member var in /usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php on line 51 I am attaching the file being tested, which is 237 lines x 8KB. It is not a stand alone file, rather a Joomla! plugin, so you can test it with phpcs but not run it directly. Actual result: -------------- PHP Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class member var in /usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php on line 51 #0 /usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php(51): PHP_CodeSniffer_File->getMemberProperties(336) #1 /usr/share/php/PHP/CodeSniffer/Standards/AbstractVariableSniff.php(154): PEAR_Sniffs_NamingConventions_ValidVariableNameSniff->processMemberVar(Object(PHP_CodeSniffer_File), 336) #2 /usr/share/php/PHP/CodeSniffer/Standards/AbstractScopeSniff.php(190): PHP_CodeSniffer_Standards_AbstractVariableSniff->processTokenWithinScope(Object(PHP_CodeSniffer_File), 336, 40) #3 /usr/share/php/PHP/CodeSniffer/File.php(431): PHP_CodeSniffer_Standards_AbstractScopeSniff->process(Object(PHP_CodeSniffer_File), 336) #4 /usr/share/php/PHP/CodeSniffer.php(900): PHP_CodeSniffer_File->start(NULL) #5 /usr/share/php/PHP/CodeSniffer.php(815): PHP_CodeSniffer->_processFile('/home/andrea/tr...', NULL) #6 in /usr/share/php/PHP/CodeSniffer/File.php on line 2047


 [2010-05-20 22:01 UTC] endi (Andrea Azzini)
No way to attach a PHP file - a pretty bad limitation for the bug tracking system IMHO. You can download the file at
 [2010-06-01 09:11 UTC] squiz (Greg Sherwood)
-Assigned To: +Assigned To: squiz
First, thank you for supplying code. It is almost impossible to debug issues like this without code. Second, the issue is caused by the comments you put between the function declaration and the opening function brace. PHPCS, when checking for a brace, stops looking after a couple of lines and assumes it wont find anything. This is to stop PHPCS looking through massive files for braces that may not be there (like inline blocks and abstract functions). I'll try and get it to ignore the rule for comments, but moving them to standard phpdoc-style function comments will stop PHPCS from being confused as well.
 [2010-06-01 11:51 UTC] endi (Andrea Azzini)
Thank you for replying. Yes, in the meantime i did some good old trial-and-error and isolated the problem in my code (and failed to report it here - sorry for that). PHPCS ran perfectly after I moved those blocks after the opening {. Anyway, the problem was kind of obscure, and the traceback was no good in solving anything, so I still wish PHPCS reported a little more explicit error descriptions... and possibly expected (arbitrarily long?) block comments mostly anywhere :)
 [2010-06-21 06:50 UTC] squiz (Greg Sherwood)
-Summary: Uncaught exception +Summary: Uncaught exception when comment before function brace
 [2010-06-21 06:52 UTC] squiz (Greg Sherwood)
-Status: Assigned +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.