public function allows(Type $type) : bool { if ($type instanceof ComposedType) { return !in_array(false, array_map([$this, 'allows'], $type->decoratedTypes())); } if ($this->type instanceof MixedType && $type instanceof ClassType) { return $type->reflection()->implementsInterface(Traversable::class); } if ($type instanceof self || $type instanceof ArrayType || $type instanceof CollectionType) { return $this->decoratedType()->allows($type->decoratedType()); } return false; }