Skip to content

[11.x] groupBy() return type phpdoc - #53684

Merged
taylorotwell merged 1 commit into
laravel:11.xfrom
lorenzolosa:group_by
Nov 27, 2024
Merged

taylorotwell merged 1 commit into
laravel:11.xfrom
lorenzolosa:group_by

Conversation

@lorenzolosa

Copy link
Copy Markdown
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
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