Hi, Am Montag, den 18.02.2008, 20:27 +0100 schrieb [EMAIL PROTECTED]: [...] > To underpin this relationship, it is possible to declare that a Trait > implements an interface like this:: > > <?php > interface IHello { > public function sayHello(); > } > > trait SayHello implements IHello { > public function sayHello() { > echo 'Hello World!'; > } > } > > class MyHelloWorld { > use SayHello; > } > > $o = new MyHelloWorld(); > var_dump($o instanceof IHello); // bool(true)
We have discussed that in IRC a bit and a lot of questions remain. The most important issue to me how to handle interface implementations in cases where methods from the interface implementing trait are renamed in the trait consumer class. I would propose to not overcomplicate things here and I see no real advantage in allowing traits to implement interfaces. I think also for the sake of conceptual integrity separating interfaces clearly from traits is a good idea: interfaces define structure while traits are function buckets. A class may use traits, may implement interfaces and may extend another class. This paradigm is pretty easy to explain to the user. cu, Lars -- Lars Strojny Senior Software Developer MediaVentures GmbH (http://mediaventures.de)
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil