Skip to content

Conversation

jnoordsij
Copy link
Contributor

As a follow-up to #56830 this PR ensures the docblock of the Collection class is adequately updated as well.

Notes:

  • I've intentionally still skipped over updating the Enumerable interface docblock here, given that updating its signature (even though only 'softly' in a docblock) should probably be considered a breaking change. I'm willing to follow-up with doing this while targetting the master branch.
  • (\cc @calebdw) I figured there might be more method docblocks for collections that currently are incomplete in not denoting their "enum support status". For example, I was looking at the groupBy docblock, which includes callable(TValue, TKey): TGroupKey but probably should be changed to say callable(TValue, TKey): TGroupKey|\BackedEnum|\Stringable given the implementation. However, when trying such things I quickly ran into errors of the sort
Unable to resolve the template type TGroupKey in call to method Illuminate\Support\Collection<X,Y>::groupBy()

so maybe this requires some additional care.

@calebdw
Copy link
Contributor

calebdw commented Sep 1, 2025

It's completely fine and not a breaking change to update the Enumerable doc block

In cases like that, the template should be left as the callable return and you can do some sort of conditional return depending on what the template type is. However, backed enums aren't generic, so not really possible to tell if it's an int or string. This may just have to be handled in a Larastan extension

@taylorotwell taylorotwell merged commit 609e2f0 into laravel:12.x Sep 1, 2025
65 checks passed
@jnoordsij jnoordsij deleted the countby-docblock-fix branch September 2, 2025 06:09
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.

3 participants