Another question on traits

From: Date: Wed, 17 Nov 2010 18:06:37 +0000
Subject: Another question on traits
Groups: php.internals 
Request: Send a blank email to internals+get-50307@lists.php.net to get a copy of this message
Hi, Simas' question yesterday lead me to take a look at the RFC on the wiki and I have a quick question. Specifically on the 'Rejected Features' -> 'Interfaces Propagation' section. So it sounds like implementing an interface directly with a trait has been shot down, what I wonder about is will it still work if a class implements an interface and uses a trait which provides the functions in said interface? <?php interface IHello { public function sayHello(); } trait SayHello { public function sayHello() { echo 'hello world'; } } class MyHelloWorld implements IHello { use SayHello; } $o = new MyHelloWorld(); var_dump($o instanceof IHello); // bool (true) ?> An explicit way to leverage traits in the inheritance tree... Is that accurate, or will that not work either? thx, -nathan

« previous php.internals (#50307) next »