From a8f29e21e8dbcf4d971d0e08a2160147187913df Mon Sep 17 00:00:00 2001 From: Caleb White Date: Tue, 10 Dec 2024 19:35:41 -0600 Subject: [PATCH] fix: php 8.4 compatibility --- README.md | 4 ++-- src/Macros/Paginate.php | 2 +- src/Macros/SimplePaginate.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d2c7788..53359c8 100644 --- a/README.md +++ b/README.md @@ -610,7 +610,7 @@ collect($posts)->paginate(5); This paginates the contents of `$posts` with 5 items per page. `paginate` accepts quite some options, head over to [the Laravel docs](https://laravel.com/docs/5.4/pagination) for an in-depth guide. ``` -paginate(int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = []) +paginate(int $perPage = 15, string $pageName = 'page', ?int $page = null, ?int $total = null, array $options = []) ``` ### `path` @@ -806,7 +806,7 @@ collect($posts)->simplePaginate(5); This paginates the contents of `$posts` with 5 items per page. `simplePaginate` accepts quite some options, head over to [the Laravel docs](https://laravel.com/docs/5.4/pagination) for an in-depth guide. ``` -simplePaginate(int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = []) +simplePaginate(int $perPage = 15, string $pageName = 'page', ?int $page = null, ?int $total = null, array $options = []) ``` For a in-depth guide on pagination, check out [the Laravel docs](https://laravel.com/docs/5.4/pagination). diff --git a/src/Macros/Paginate.php b/src/Macros/Paginate.php index 64688a7..6a82b6a 100644 --- a/src/Macros/Paginate.php +++ b/src/Macros/Paginate.php @@ -20,7 +20,7 @@ class Paginate { public function __invoke() { - return function (int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = []): LengthAwarePaginator { + return function (int $perPage = 15, string $pageName = 'page', ?int $page = null, ?int $total = null, array $options = []): LengthAwarePaginator { $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); $results = $this->forPage($page, $perPage)->values(); diff --git a/src/Macros/SimplePaginate.php b/src/Macros/SimplePaginate.php index 04d4745..5b1fa3b 100644 --- a/src/Macros/SimplePaginate.php +++ b/src/Macros/SimplePaginate.php @@ -19,7 +19,7 @@ class SimplePaginate { public function __invoke() { - return function (int $perPage = 15, string $pageName = 'page', int $page = null, array $options = []): Paginator { + return function (int $perPage = 15, string $pageName = 'page', ?int $page = null, array $options = []): Paginator { $page = $page ?: Paginator::resolveCurrentPage($pageName); $results = $this->slice(($page - 1) * $perPage)->take($perPage + 1);