add generic return types to Builder paginate methods#60045
Merged
taylorotwell merged 1 commit intoMay 8, 2026
Merged
Conversation
This was referenced May 8, 2026
Open
Contributor
Author
|
asking for a friend: how do you backport a docblock change to laravel 12.x + 11.x? |
This was referenced May 8, 2026
taylorotwell
pushed a commit
that referenced
this pull request
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
Illuminate\Database\Eloquent\Builderalready declares@template TModel of \Illuminate\Database\Eloquent\Modelat the class level, and the three paginator classes (LengthAwarePaginator,Paginator,CursorPaginator) already declare@template TKey of array-keyand@template-covariant TValue. this change threads the two together by adding generic return type annotations to the three paginate methods onBuilder.before:
after:
why
without these annotations, static analysis tools have no way to carry the model type through a paginator. a call like
Product::paginate(5)resolves to an untypedLengthAwarePaginator, so tools that inspect the return shape (eg. for Inertia type generation) fall back todata: Record<string, unknown>instead of emittingdata: Product[].this is a docblock-only change; no runtime behavior is affected.
related
@templatebindings inArrayableshapes andBuildermethod return types surveyor#39merge order
this->laravel/surveyor->laravel/wayfinder