Hi Richard, > A question (and again, no idea on feasibility, internals, etc.). > > The above proposal covers adding/overriding internal methods with > external ones. Is it possible to also include additional properties? > > If not, then you would have to override the constructor method (this > could be demoted to documentation rather than code then I suppose). the current proposal does not allow state in your traits.
At the moment the solution would be like this: trait A { abstract protected function getFoo(); public function doSomeFoo($bar) { return $this->getFoo().' baz ' . $bar; } } Traits can defined abstract methods to define a required method. This abstract methods can be implemented in the class or in an other trait. There are also notions about stateful traits out there. For instance Scala does implement them, but state is an additional level of complexity and I have tried to avoid it in this implementation, since I have had expected much more complains about the aliasing and exclude operations and its pretended complexity. In my opinion stateful traits are the next logical step, but with the cost for some additional complexity, since you need handle conflicting properties. (The stateful traits approach is to make it private to a traits composition, but this might not be obvious to every user.) Kind Regards Stefan -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php