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

Bug #18762 Incorrect handling of define and constant in UpperCaseConstantNameSniff (patch)
Submitted: 2011-08-28 07:49 UTC
From: bakert Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0)
PHP Version: 5.3.1 OS: OS X Snow Leopard
Roadmaps: (Not assigned)    
Subscription  


 [2011-08-28 07:49 UTC] bakert (Thomas Baker)
Description: ------------ UpperCaseConstantNameSniff treats static methods named "define" and "constant" as if they were the PHP "define" and "constant" which gives false positives in UpperCaseConstantNameSniff. The following patch will fix: 162c162,163 < if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR) { --- > if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR > || $tokens[$prev]['code'] === T_DOUBLE_COLON) { Test script: --------------- <?php class A { public static function constant($x) {} } A::constant('anything-not-in-uppercase'); // Now run phpcs on this file Expected result: ---------------- No output. Actual result: -------------- Constants must be uppercase; expected 'ANYTHING-NOT-ALL- CAPS' but found 'anything-not-all-caps'

Comments

 [2011-09-03 19:51 UTC] bakert (Thomas Baker)
 [2011-09-12 09:38 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
This bug has been fixed in SVN. 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. Thanks for the patch.