Skip to content

Builder::paginate() Return value type is incorrect #741

@Yi-pixel

Description

@Yi-pixel

Hi,This problem has been bothering me.Because it still exists in multiple versions.

When I try to call the paginate() method at the end of the model, the return value it gives me should be
Illuminate\Pagination\LengthAwarePaginator Instead of \Illuminate\Contracts\Pagination\LengthAwarePaginator defined in _ide_helper.php, Although this should not seem too much of a problem, because \Illuminate\Contracts\Pagination\LengthAwarePaginator implements Illuminate\Contracts\Support\Arrayable which makes it possible to call the toArray method after paginate() Serialize, then modify the data column inside, although it is now working, but in PHPStorm will show the exception highlighting of the method does not exist.
Because I know this may not be a bug, or because of some features such as Contracts, so I didn't intend to submit a pull request, so I would like to ask if I can solve this problem.


Of course, I do this because I need to modify the data in the return value of paginate() and keep the original paging data structure. Maybe you can have better.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions