Skip to content

Conversation

@lorenzolosa
Copy link
Contributor

In the current phpdoc, the return type of Collection::groupBy() is assumed to be a collection with the same values as the original one. However, when the grouping is specified with an array of two or more keys (e.g., $collection->groupBy(['key1', 'key2'])), the result is a multi-level collection (i.e., a collection of collections).

This PR changes the return type so that it doesn't make assumptions on the collection values when the grouping is specified with an array - while leaving it as it is when it's a single key or a function.

If this PR is merged, I'll make a corresponding PR to larastan, as it contains stubs for these classes/interfaces.

@taylorotwell taylorotwell merged commit b1f07ed into laravel:11.x Nov 27, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants