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

Request #13820 add INDENT pattern to AbstractPatternSniff class
Submitted: 2008-05-02 08:59 UTC
From: agastiya Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.0.1)
PHP Version: 5.2.5 OS: osx
Roadmaps: 1.1.0    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 24 - 5 = ?

 
 [2008-05-02 08:59 UTC] agastiya (Agastiya S. Mohammad)
Description: ------------ INDENT pattern will allow us to define Bsd/Allman bracing style to control structures easily. Currently, Bsd/Allman bracing style is only define in T_FUNCTION token. What I can do now to define this is to extend Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php, and overload the register() method to include control structures ie. T_IF, T_WHILE, etc, besides the default T_FUNCTION. The downside is that the error message is not clear because we cannot change the word 'function' within the message. Test script: --------------- function is_ok($a) { if ($a == 1) { return 'ok'; } else { return 'not ok'; } }

Comments

 [2008-05-04 22:51 UTC] squiz (Greg Sherwood)
I can easily change the error message to use the name of the token instead of hard-coding the word "function". Adding an INDENT pattern would be pretty hard because indentation is not something easily determined by that pattern sniff.
 [2008-05-05 03:59 UTC] squiz (Greg Sherwood)
I've just removed the word "function" from the error messages because it was not always used anyway and is the easiest fix. The error messages are now generic and the class can be extended without the error messages becoming misleading.
 [2008-05-05 04:00 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.