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

Bug #20138 Protected property underscore and camel caps issue (in trait with Zend)
Submitted: 2013-11-29 20:45 UTC
From: naelyth Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.0)
PHP Version: 5.4.21 OS:
Roadmaps: (Not assigned)    
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:
Solve the problem : 40 - 21 = ?

 [2013-11-29 20:45 UTC] naelyth (Gaetan Rousseau)
Description: ------------ The problem has olready spotted here ( and I find a solution to solve it. It's realy simple, you just have ton changes 2 lines in CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php Line 122 and 229 when use the function "hasCondition", add the T_TRAIT in the array passed. Test script: --------------- l.122 $inClass = $phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE, T_TRAIT)); l.229 if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_INTERFACE, T_TRAIT)) === true) { Actual result: -------------- With that, CodeSniffer will use the class naming standards in the trait, so the error : "ERROR | Variable "_myVariable" is not in valid camel caps format" will not appear anymore. If you can implement that directly in CodeSniffer, that will help some guys.


 [2013-12-02 06:54 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Thanks, I've committed those changes here: ef3ac40b92855b