These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Illuminate\Support\Collection; |
||
4 | use Illuminate\Pagination\LengthAwarePaginator; |
||
5 | |||
6 | /* |
||
7 | * Paginate the given collection |
||
8 | * |
||
9 | * @param int $perPage |
||
10 | * @param int $total |
||
11 | * @param int $page |
||
12 | * @param string $pageName |
||
13 | * |
||
14 | * @return \Illuminate\Pagination\LengthAwarePaginator |
||
15 | */ |
||
16 | Collection::macro('paginate', function (int $perPage = 15, string $pageName = 'page', int $page = null, int $total = null, array $options = []): LengthAwarePaginator { |
||
17 | $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName); |
||
18 | |||
19 | $results = $this->forPage($page, $perPage); |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | $total = $total ?: $this->count(); |
||
22 | |||
23 | $options += [ |
||
24 | 'path' => LengthAwarePaginator::resolveCurrentPath(), |
||
25 | 'pageName' => $pageName, |
||
26 | ]; |
||
27 | |||
28 | return new LengthAwarePaginator($results, $total, $perPage, $page, $options); |
||
29 | }); |
||
30 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.