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

[11.x] Enhanced typing for HigherOrderCollectionProxy #52484

Merged

Conversation

Voltra
Copy link
Contributor

@Voltra Voltra commented Aug 14, 2024

HigherOrderCollectionProxy is a great feature of Laravel that helps reduce boilerplate code. Sadly there is no out-of-the-box decent auto-completion for it.

This PR makes HigherOrderCollectionProxy a templated type (as is Enumerable, Collection and EnumeratesValues) that aims to help IDEs provide auto-completion based on the collection's value type.

  • What's been added: Nothing
  • What's been modified: Docblocks to add and use the template type parameters
  • Tests: none needed, no changes in code; auto-completion changes were tested in PHPStorm
  • Hard breaking changes: none, no changes in code
  • Soft breaking changes: Library authors that use HigherOrderCollectionProxy might want to update docblocks to include the correct template type parameters
  • Room for improvement: As of now, this PR cannot properly type chains of HigherOrderCollectionProxy like $coll->keyBy->id->map->value->toArray()

@taylorotwell
Copy link
Member

I think we have type tests - can you add one?

@taylorotwell taylorotwell marked this pull request as draft August 14, 2024 21:56
@Voltra
Copy link
Contributor Author

Voltra commented Aug 15, 2024

I'll take a look at that

@Voltra Voltra marked this pull request as ready for review August 17, 2024 20:44
@taylorotwell
Copy link
Member

There are a lot of unrelated changes here.

@taylorotwell taylorotwell marked this pull request as draft August 17, 2024 20:57
@Voltra Voltra force-pushed the feature/BETTER_TYPES_FOR_COLLECTIONS branch from b616578 to ec27f7d Compare August 18, 2024 11:44
@Voltra Voltra marked this pull request as ready for review August 18, 2024 11:49
@Voltra
Copy link
Contributor Author

Voltra commented Aug 18, 2024

My apologies, this should fix it

@taylorotwell taylorotwell merged commit 9c2f7f8 into laravel:11.x Aug 19, 2024
28 of 29 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