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

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)    
Subscription  


 [2013-11-29 20:45 UTC] naelyth (Gaetan Rousseau)
Description: ------------ The problem has olready spotted here (http://pear.php.net/bugs/bug.php?id=19490) 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.

Comments

 [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: https://github.com/squizlabs/PHP_CodeSniffer/commit/b574c8465331ac48e7c96fa175 ef3ac40b92855b