/**
* @template TKey
* @template T
*/
interface Chunkable
{
/**
* Chunk a collection of items into chunks of items of a given size.
*
* @see https://loophp-collection.readthedocs.io/en/stable/pages/api.html#chunk
*
* @return Collection<int, list<T>>
*/
public function chunk(int ...$sizes): Collection;
}
As you can see, this operation returns Collection<int, list<T>>, which is fair.
Yet, since after applying chunk(), each produced chunk can will never be empty list.
Therefore, maybe it would make sense to specify Collection<int, non-empty-list<T>> as a return type, since this is more specific.
Currently
Chunkable
interface looks like this:As you can see, this operation returns
Collection<int, list<T>>
, which is fair.Yet, since after applying
chunk()
, each produced chunk can will never be empty list.Therefore, maybe it would make sense to specify
Collection<int, non-empty-list<T>>
as a return type, since this is more specific.