laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.63k stars 11.03k forks source link

Fix Paginator __construct parameter typehint for phpstan #53615

Closed Afrowson closed 17 hours ago

Afrowson commented 22 hours ago

Since the update to v11.32.0 this commit introduced type hints for the Paginator Class. The @param for $items was defined too narrow, restricting the use of Collections, but they are supported and it seems like to be preffered, as the protected setItems() method which is called from within the constructor is supporting Collections and converts any array in to one.

This is not a bugfix as the code works, but a type fix supporting the usage of phpstan/larastan

This PR broadens the type hint for the param $items to be compatible with setItems() by allowing Collections with Tkey and TValue

I did not add null as allowed, although it is supported in the setItems method, but maybe that should be supported as well?