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

Bug #13178 Catch exception in File.php
Submitted: 2008-02-22 10:17 UTC
From: luebbert42 Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.1)
PHP Version: 5.2.5 OS: Linux
Roadmaps: (Not assigned)    

 [2008-02-22 10:17 UTC] luebbert42 (Dorthe Luebbert)
Description: ------------ Due to an unresolved merge conflict we got code like the code listed below (functions in functions). PHP 5.2.5 CLI accepts this code ("checking with php -l"). Testing the code with codesniffer against Pear oder Zend standard I got an fatal uncaught exception " is not a class member var" from File.php. It would be nice to catch this exception and print the line out where the error occured in the checked file. Test script: --------------- <?php class something { public function getData() { print "foo"; function doA() { return $a; } function doB() { return $b; } print "bar"; return $data; } } ?> Expected result: ---------------- no fatal error from code_sniffer Actual result: -------------- Fatal error: Uncaught PHP_CodeSniffer_Exception


 [2008-02-22 11:29 UTC] luebbert42 (Dorthe Luebbert)
Ok, I did not know that the function in function construction is allowed in PHP (I thought accepting this code was a bug of the php parser). So I changed the bug type from wishlist to bug as code_sniffer should be able to parse my strange code without failing...
 [2008-02-26 04:23 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. 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. Was a problem specifically with the AbstractVariableSniff abstract class not supporting nested functions. This caused PEAR ValidVariableNameSniff to incorrectly assume $data was a class member var.