public function __construct(ClassType $class, Type $generic) { $this->class = $class; $this->generic = new IterableType($generic); if (!$class->reflection()->implementsInterface(Traversable::class)) { throw new InvalidArgumentException('Class ' . $class->reflection()->name() . ' is not traversable'); } parent::__construct($class->reflection()); }
function let(ClassType $collection, ClassReflection $reflection, Type $generic) { $reflection->implementsInterface(Traversable::class)->willReturn(true); $collection->reflection()->willReturn($reflection); $this->beConstructedWith($collection, $generic); }