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

Bug #14077 Fatal error: Uncaught PHP_CodeSniffer_Exception: $stackPtr is not a class membe
Submitted: 2008-06-05 03:29 UTC
From: doconnor Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.1)
PHP Version: 5.2.6 OS:
Roadmaps: 1.1.0    
Subscription  


 [2008-06-05 03:29 UTC] doconnor (Daniel O'Connor)
Description: ------------ Unexpected exception when processing code - I have nfi which file is triggering this (but will try to find out!) Test script: --------------- phpcs Expected result: ---------------- No unhandled exceptions / errors in this instance Actual result: -------------- 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 52 #0 /usr/share/php/PHP/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php(52): PHP_CodeSniffer_File->getMemberProperties(4645) #1 /usr/share/php/PHP/CodeSniffer/Standards/AbstractVariableSniff.php(139): PEAR_Sniffs_NamingConventions_ValidVariableNameSniff->processMemberVar(Object(PHP_CodeSniffer_File), 4645) #2 /usr/share/php/PHP/CodeSniffer/Standards/AbstractScopeSniff.php(178): PHP_CodeSniffer_Standards_AbstractVariableSniff->processTokenWithinScope(Object(PHP_CodeSniffer_File), 4645, 1) #3 /usr/share/php/PHP/CodeSniffer/File.php(479): PHP_CodeSniffer_Standards_AbstractScopeSniff->process(Object(PHP_CodeSniffer_File), 4645) #4 /usr/share/php/PHP/CodeSniffer.php(560): PHP_CodeSniffer_File->start() #5 /usr/share/php/PHP/CodeSniffer.php(514): PHP_CodeSniffer->processFile('/usr/files/trun...') #6 /usr/sh in /usr/share/php/PHP/CodeSniffer/File.php on line 1918

Comments

 [2008-06-05 03:35 UTC] doconnor (Daniel O'Connor)
Annoyingly, this works just fine in 5.2.6 for the particular file. If you wanted to flick me an email I can provide the particular code somewhere non-public
 [2008-06-05 03:54 UTC] doconnor (Daniel O'Connor)
Oops, my local copy was using the wrong coding standard - it does happen on 5.2.6
 [2008-06-05 03:58 UTC] doconnor (Daniel O'Connor)
Ah hah! <?php class Foo { public static function bar() { function anonFunction() { } $var = true; } } ?> Inline functions throw off parsing :)
 [2008-06-05 06:05 UTC] squiz (Greg Sherwood)
Thank you for taking the time to report a problem with the package. Unfortunately you are not using a current version of the package -- the problem might already be fixed. Please download a new version from http://pear.php.net/packages.php If you are able to reproduce the bug with one of the latest versions, please change the package version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PEAR. Try installing 1.1.0RC1. I think it is fixed in this version.
 [2008-06-05 06:42 UTC] doconnor (Daniel O'Connor)
alright -> WFM :)
 [2008-06-19 15:50 UTC] wloche (Wilfried Loche)
Hello, Here is another example that also fails with phpcs <?php function supprimeDefPopulationExclusionByCritere($cc, $cv) { if (!$this->dbIsParsed(__METHOD__ . $cc . "-len(" . strlen($cv) . ")")) { $req = "delete from T_V5_GDE where ID = :ID and not (POP_{$cc}_A = '{$this->def["POP_{$cc}_A"]}' and POP_{$cc}_A = '{$this->def["POP_{$cc}_A"]}')"; } } /** * Gestion des parametres GDE * * @package Kgde * @subpackage Parametres */ class Parametres extends AutoCommitDataBase { function supprimeDefPopulationExclusionByCritere($cc, $cv) { if (!$this->dbIsParsed(__METHOD__ . $cc . "-len(" . strlen($cv) . ")")) { $req = "delete from T_V5_GDE where ID = :ID and not (POP_{$cc}_A = '{$this->def["POP_{$cc}_A"]}' and POP_{$cc}_B = '{$this->def["POP_{$cc}_B"]}')"; } } } ?> To get it "right", I added a try/catch arround $memberProps = $phpcsFile->getMemberProperties($stackPtr) on line 151, of the file /CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php. I use the 1.0.1 release, does-it already fixed in the RC1 ? Thx for this great tool, Wilfried Loche
 [2008-06-20 03:33 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net 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. Was caused by the double quotes within the double-quoted string. I had to change the parsing code a bit rather than the sniff, which was working correctly. Thanks a lot for submitting this code Wilfried. It would have been impossible to track down without it.
 [2008-06-23 08:10 UTC] wloche (Wilfried Loche)
Thx to you Greg, to bring us such a tool :)