Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More specific Chunkable::chunk() return type #350

Closed
rela589n opened this issue Nov 26, 2024 · 4 comments
Closed

More specific Chunkable::chunk() return type #350

rela589n opened this issue Nov 26, 2024 · 4 comments
Labels

Comments

@rela589n
Copy link
Contributor

Currently Chunkable interface looks like this:

/**
 * @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.

@drupol
Copy link
Collaborator

drupol commented Nov 26, 2024

Hello,

Yes! Nice catch.

Please submit a PR to fix this and I'll merge it.

Copy link

github-actions bot commented Dec 1, 2024

Since this issue has not had any activity within the last 5 days, I have marked it as stale.
I will close it if no further activity occurs within the next 5 days.

@github-actions github-actions bot added the stale label Dec 1, 2024
@drupol drupol removed the stale label Dec 4, 2024
Copy link

github-actions bot commented Dec 9, 2024

Since this issue has not had any activity within the last 5 days, I have marked it as stale.
I will close it if no further activity occurs within the next 5 days.

@github-actions github-actions bot added the stale label Dec 9, 2024
@rela589n
Copy link
Contributor Author

Closing as completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants