Traits for PHP
During the last six months I’ve studied a language construct called Traits. It is a construct enabling fine-grained code reuse beside single inheritance in classical object oriented languages. A first implementation of this concept has been around for Squeak. Since I’ve used PHP already for a quite long time now, I decided to dig into its internals and implement Traits for PHP, too.
In my opinion PHP seams to be an almost perfect candidate to introduce Traits as a language construct since it is a dynamic object-oriented class-based programming language with a Java-like inheritance concept. Now, I’ll try to convince the PHP people out there and may be we will see some PHP5.x with Traits support in some month from now.
A good starting point is the Request for Comments I have written for the mailing list. The RFC deals with the questions what Traits are, how they are used, why they are useful, and how they look like in PHP. A patch implementing this new language construct is available, too.
So please, give it a try :)