Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (188)

Classes/Pagination/PageGridPagination.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
7
 *
8
 * This file is part of the Kitodo and TYPO3 projects.
9
 *
10
 * @license GNU General Public License version 3 or later.
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 */
14
15
namespace Kitodo\Dlf\Pagination;
16
17
use TYPO3\CMS\Core\Pagination\PaginationInterface;
18
use TYPO3\CMS\Core\Pagination\PaginatorInterface;
19
20
21
final class PageGridPagination implements PaginationInterface
22
{
23
    /**
24
     * @var PageGridPaginator
25
     */
26
    protected $paginator;
27
28
    public function __construct(PaginatorInterface $paginator)
29
    {
30
        // @phpstan-ignore-next-line
31
        $this->paginator = $paginator;
0 ignored issues
show
Documentation Bug introduced by
$paginator is of type TYPO3\CMS\Core\Pagination\PaginatorInterface, but the property $paginator was declared to be of type Kitodo\Dlf\Pagination\PageGridPaginator. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
32
    }
33
34
    public function getPreviousPageNumber(): ?int
35
    {
36
        $previousPage = (int) (($this->paginator->getCurrentPageNumber() - 1) * $this->paginator->getPublicItemsPerPage()) - ($this->paginator->getPublicItemsPerPage() - 1);
37
38
        if ($previousPage > $this->paginator->getNumberOfPages()) {
39
            return null;
40
        }
41
42
        return $previousPage >= $this->getFirstPageNumber()
43
            ? $previousPage
44
            : null
45
            ;
46
    }
47
48
    public function getNextPageNumber(): ?int
49
    {
50
        $nextPage = (int) ($this->paginator->getCurrentPageNumber() * count($this->paginator->getPaginatedItems()) + 1);
51
52
        return $nextPage <= $this->paginator->getNumberOfPages()
53
            ? $nextPage
54
            : null
55
            ;
56
    }
57
58
    public function getFirstPageNumber(): int
59
    {
60
        return 1;
61
    }
62
63
    public function getLastPageNumber(): int
64
    {
65
        return $this->paginator->getNumberOfPages();
66
    }
67
68
    public function getStartRecordNumber(): int
69
    {
70
        if ($this->paginator->getCurrentPageNumber() > $this->paginator->getNumberOfPages()) {
71
            return 0;
72
        }
73
74
        return $this->paginator->getKeyOfFirstPaginatedItem() + 1;
75
    }
76
77
    public function getEndRecordNumber(): int
78
    {
79
        if ($this->paginator->getCurrentPageNumber() > $this->paginator->getNumberOfPages()) {
80
            return 0;
81
        }
82
83
        return $this->paginator->getKeyOfLastPaginatedItem() + 1;
84
    }
85
86
    /**
87
     * @return int[]
88
     */
89
    public function getAllPageNumbers(): array
90
    {
91
        return range($this->getFirstPageNumber(), $this->getLastPageNumber());
92
    }
93
}
94