czim / laravel-repository

Repository pattern implementation for Laravel
MIT License
51 stars 19 forks source link

Wrote a more complete contract for LengthAwarePaginator #6

Closed dennis-koster closed 7 years ago

dennis-koster commented 7 years ago

The paginate() method of the BaseRepository class returns Illuminate\Contracts\Pagination\LengthAwarePaginator as the interface in the docblock. However, that interface is incomplete, because the actual Illuminate\Pagination\LengthAwarePaginator class implement many more methods, such as count().

czim commented 7 years ago

Hmm.. The problem with this is that the method does not actually return anything implementing that interface. This would help the IDE, but at the cost of lying about the return value.

This is the direct effect of the fact that the Illuminate paginator class does not have its own interface.

I think it would be better to add the LengthAwarePaginator itself to the @return clause. That would be correct and help the IDE.