-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Description
- Laravel Version: 9.17.0
- PHP Version: 8.1.2
Description:
Hi, this is a very minor issue. I was trying check whether a route is paginated using Illuminate\Pagination\Paginator::resolveCurrentPage(default: false). Even though no pagination is ongoing, this returns 1 rather than false. Maybe it would be possible to return null in the default currentPageResolver:
framework/src/Illuminate/Pagination/PaginationState.php
Lines 19 to 27 in c41c1b3
| Paginator::currentPageResolver(function ($pageName = 'page') use ($app) { | |
| $page = $app['request']->input($pageName); | |
| if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { | |
| return (int) $page; | |
| } | |
| return 1; | |
| }); |
The default value passed to resolveCurrentPage could then be returned by checking for null:
framework/src/Illuminate/Pagination/AbstractPaginator.php
Lines 505 to 512 in b9203fc
| public static function resolveCurrentPage($pageName = 'page', $default = 1) | |
| { | |
| if (isset(static::$currentPageResolver)) { | |
| return (int) call_user_func(static::$currentPageResolver, $pageName); | |
| } | |
| return $default; | |
| } |
Steps To Reproduce:
- In a route, invoke
Illuminate\Pagination\Paginator::resolveCurrentPage(default: false)when there is no pagination. - 1 is returned, rather than false.
Metadata
Metadata
Assignees
Labels
No labels