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

Update the return typehints for the fluent methods on the Paginator. #14

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

patrickcarlohickman
Copy link

@patrickcarlohickman patrickcarlohickman commented May 31, 2024

This PR updates the return typehints for two of the fluent methods on the Paginator. The setMaxPages() and setPerPageLimit() methods were defined to return Paginator instances, but this has been updated to use the static keyword. This improves intellisense in IDEs.

For example, if you have the following method chain (connector is using a PagedPaginator):

$this
    ->connector
    ->paginate(new MyPagedRequest())
    ->setPerPageLimit(10)
    ->pool();

In this example, intellisense will complain that the pool() method doesn't exist. This is because the setPerPageLimit() is defined to return a Paginator instance, and that does not have the pool() method defined. However, the method actually returns a PagedPaginator, which does have the pool() method, and will work correctly. By updating the return type to static, intellisense will be able to resolve the correct returned instance type and see that the pool() method is valid.

As a note, the setStartPage() fluent method already correctly uses the static return typehint, so this is not a new thing for this class.

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.

1 participant