I want to make a PHP's Iterators using my trait named Iterative. I tried to do this in this way:
-
Trait Iterative "implements" interface Traversable
trait Iterative { public function rewind(){ /* ... */ } public function current(){ /* ... */ } public function key(){ /* ... */ } public function next(){ /* ... */ } public function valid(){ /* ... */ } }
-
Class BasicIterator should implements the interface using trait
class BasicIterator implements \Traversable { use Iterative; }
but i get:
Fatal error: Class BasicIterator must implement interface Traversable as part of either Iterator or IteratorAggregate in Unknown on line 0
Is it even possible and in what way?