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

Request #14967 Allow relative paths to specify location of custom coding standards
Submitted: 2008-11-07 00:30 UTC
From: chalia Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.1.0)
PHP Version: 5.2.0 OS: Debian
Roadmaps: (Not assigned)    
Subscription  


 [2008-11-07 00:30 UTC] chalia (Charlie Cheng)
Description: ------------ I have a class as following: <?php if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) { throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_CodingStandard not found'); } class PHP_CodeSniffer_Standards_IcsStandard_IcsStandardCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard { public function getIncludedSniffs() { return array( 'MySource', ); }//end getIncludedSniffs() public function getExcludedSniffs() { return array(); } }//end class ?> When I run command line as following: phpcs --standard=dev_tools/code_sniffer/IcsStandard/ -v ics_con.php3 The screen shows: Registering sniffs in dev_tools/code_sniffer/IcsStandard/ standard... DONE (0 sniffs registered) Processing ics_con.php3 [1171 tokens in 226 lines]... DONE in < 1 second (0 errors, 0 warnings) And I have tried to run command line as following to compare: phpcs --standard=MySource ics_con.php3 The message was shown as following: FILE: /home/developer/public_html/ics_misc_fixes/ics_con.php3 -------------------------------------------------------------------------------- FOUND 361 ERROR(S) AND 42 WARNING(S) AFFECTING 170 LINE(S) -------------------------------------------------------------------------------- ... My guess will be the override of function getIncludedSniffs doesn't work. Test script: --------------- <?php if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) { throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_CodingStandard not found'); } class PHP_CodeSniffer_Standards_IcsStandard_IcsStandardCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard { public function getIncludedSniffs() { return array( 'MySource', ); }//end getIncludedSniffs() public function getExcludedSniffs() { return array(); } }//end class ?> Expected result: ---------------- There should have some warning message shown and in the same time, registered sniffs should not be zero. Actual result: -------------- registered sniffs is zero. And no warning message is given.

Comments

 [2008-11-13 22:22 UTC] squiz (Greg Sherwood)
Try using the full path to your coding standard dir instead of a relative path.
 [2008-11-13 22:58 UTC] squiz (Greg Sherwood)
Turning this into a feature request to be able to use relative paths for custom standards.
 [2009-07-06 07:52 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
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. You can now use a relative path. You get output like: gsherwood$ phpcs --standard=Ics temp.php -v Registering sniffs in Ics standard... DONE (130 sniffs registered) Processing temp.php [31 tokens in 8 lines]... DONE in < 1 second (3 errors, 0 warnings)