Skip to content

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.

@patrickcarlohickman
Copy link
Author

Ping @Sammyjo20

@Sammyjo20
Copy link
Member

Thanks @patrickcarlohickman I will take a look at this at the weekend! 👍

@patrickcarlohickman
Copy link
Author

Ping @Sammyjo20 🙂

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