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

Bug #19957 Does not understand trait method aliasing
Submitted: 2013-05-25 17:29 UTC
From: macnibblet Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version Unknown)
PHP Version: 5.4.0 OS: OS X
Roadmaps: (Not assigned)    
Subscription  


 [2013-05-25 17:29 UTC] macnibblet (Antoine Hedgecock)
Description: ------------ PHPCs this trait method aliasing is constants.. Test script: --------------- class Foo { use ListenerAggregateTrait, PreLoadUserTrait, PreLoadCompanyTrait { PreloadUserTrait::PreLoadUser as loadUser; PreloadCompanyTrait::PreLoadCompany as loadCompany; } } Actual result: -------------- [exec] [exec] FILE: ...ine/Sites/................ [exec] ----------------------------------------------------------- --------------------- [exec] FOUND 2 ERROR(S) AFFECTING 2 LINE(S) [exec] ----------------------------------------------------------- --------------------- [exec] 30 | ERROR | Constants must be uppercase; expected PRELOADUSER but found [exec] | | PreLoadUser [exec] 31 | ERROR | Constants must be uppercase; expected PRELOADCOMPANY but found [exec] | | PreLoadCompany [exec] ----------------------------------------------------------- --------------------- [exec] [exec] Time: 1 second, Memory: 6.50Mb [exec]

Comments

 [2013-06-03 06:05 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
Fix committed to github repo: https://github.com/squizlabs/PHP_CodeSniffer/commit/8cb66e3d32a173504ceb5591e 36e04c7f9c5ad12
 [2013-08-03 02:43 UTC] luke_stoysnet (Lucas Green)
This seems to still fail when there is only one "used" trait and the method name is unqualified: ------- trait Foo{ use Bar { get as protected getter; set as protected setter; delete as protected unsetter; exists as protected issetter; } } -------
 [2013-08-03 02:47 UTC] luke_stoysnet (Lucas Green)
nevermind, I must be missing something
 [2013-08-03 03:38 UTC] luke_stoysnet (Lucas Green)
Ah, that's what it is. The visibility modifiers (private, public, protected) seem to throw it off. When present, the method rename is recognized as a constant and not a method.
 [2013-08-31 00:46 UTC] markstory (Mark Story)
I don't think this is completely solved. Using the 1.5.0RC3 release, I still see: ERROR | Constants must be uppercase; expected _CONFIG but found _config For code like: class Foo { use BarTrait; use FirstTrait { config as protected _config; } }