mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 19:43:49 +00:00
DX: fix phpstan errors
This commit is contained in:
@@ -26,21 +26,21 @@ class Paginator implements PaginatorInterface
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $currentPageNumber;
|
||||
protected int $currentPageNumber;
|
||||
|
||||
/**
|
||||
* the number of items on a single page.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $itemPerPage;
|
||||
protected int $itemPerPage;
|
||||
|
||||
/**
|
||||
* the key in the GET parameter to indicate the number of item per page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $itemPerPageKey;
|
||||
protected string $itemPerPageKey;
|
||||
|
||||
/**
|
||||
* the key in the GET parameter to indicate the page number in
|
||||
@@ -48,45 +48,45 @@ class Paginator implements PaginatorInterface
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pageKey;
|
||||
protected string $pageKey;
|
||||
|
||||
/**
|
||||
* the route of the pages.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $route;
|
||||
protected string $route;
|
||||
|
||||
/**
|
||||
* the parameters of the route.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $routeParameters;
|
||||
protected array $routeParameters;
|
||||
|
||||
/**
|
||||
* The number of total items.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $totalItems;
|
||||
protected int $totalItems;
|
||||
|
||||
/**
|
||||
* the generator for url.
|
||||
*
|
||||
* @var UrlGeneratorInterface
|
||||
*/
|
||||
protected $urlGenerator;
|
||||
protected UrlGeneratorInterface $urlGenerator;
|
||||
|
||||
public function __construct(
|
||||
$totalItems,
|
||||
$itemPerPage,
|
||||
$currentPageNumber,
|
||||
$route,
|
||||
int $totalItems,
|
||||
int $itemPerPage,
|
||||
int $currentPageNumber,
|
||||
string $route,
|
||||
array $routeParameters,
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
$pageKey,
|
||||
$itemPerPageKey
|
||||
string $pageKey,
|
||||
string $itemPerPageKey
|
||||
) {
|
||||
$this->totalItems = $totalItems;
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
@@ -98,12 +98,12 @@ class Paginator implements PaginatorInterface
|
||||
$this->itemPerPageKey = $itemPerPageKey;
|
||||
}
|
||||
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return $this->countPages();
|
||||
}
|
||||
|
||||
public function countPages()
|
||||
public function countPages(): int
|
||||
{
|
||||
if (0 === $this->itemPerPage) {
|
||||
return 1;
|
||||
@@ -122,20 +122,17 @@ class Paginator implements PaginatorInterface
|
||||
return 0 === $nb ? 1 : (int) $nb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Chill\MainBundle\Pagination\Page
|
||||
*/
|
||||
public function getCurrentPage()
|
||||
public function getCurrentPage(): Page
|
||||
{
|
||||
return $this->getPage($this->currentPageNumber);
|
||||
}
|
||||
|
||||
public function getCurrentPageFirstItemNumber()
|
||||
public function getCurrentPageFirstItemNumber(): int
|
||||
{
|
||||
return $this->getCurrentPage()->getFirstItemNumber();
|
||||
}
|
||||
|
||||
public function getItemsPerPage()
|
||||
public function getItemsPerPage(): int
|
||||
{
|
||||
return $this->itemPerPage;
|
||||
}
|
||||
@@ -145,7 +142,7 @@ class Paginator implements PaginatorInterface
|
||||
*
|
||||
* @return \Chill\MainBundle\Pagination\Page
|
||||
*/
|
||||
public function getNextPage()
|
||||
public function getNextPage(): Page
|
||||
{
|
||||
if (!$this->hasNextPage()) {
|
||||
throw new RuntimeException('this page has no next page');
|
||||
@@ -155,11 +152,10 @@ class Paginator implements PaginatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type $number
|
||||
*
|
||||
* @return \Chill\MainBundle\Pagination\Page
|
||||
*/
|
||||
public function getPage($number)
|
||||
public function getPage(int $number): Page
|
||||
{
|
||||
if (!$this->hasPage($number)) {
|
||||
throw new RuntimeException("The page with number {$number} does not "
|
||||
@@ -179,7 +175,7 @@ class Paginator implements PaginatorInterface
|
||||
);
|
||||
}
|
||||
|
||||
public function getPagesGenerator()
|
||||
public function getPagesGenerator(): iterable
|
||||
{
|
||||
for ($i = 1; $this->countPages() >= $i; ++$i) {
|
||||
yield $this->getPage($i);
|
||||
@@ -191,7 +187,7 @@ class Paginator implements PaginatorInterface
|
||||
*
|
||||
* @return \Chill\MainBundle\Pagination\Page
|
||||
*/
|
||||
public function getPreviousPage()
|
||||
public function getPreviousPage(): PageInterface
|
||||
{
|
||||
if (!$this->hasPreviousPage()) {
|
||||
throw new RuntimeException('this page has no previous page');
|
||||
@@ -200,7 +196,7 @@ class Paginator implements PaginatorInterface
|
||||
return $this->getPage($this->currentPageNumber - 1);
|
||||
}
|
||||
|
||||
public function getTotalItems()
|
||||
public function getTotalItems(): int
|
||||
{
|
||||
return $this->totalItems;
|
||||
}
|
||||
@@ -208,12 +204,12 @@ class Paginator implements PaginatorInterface
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasNextPage()
|
||||
public function hasNextPage(): bool
|
||||
{
|
||||
return $this->hasPage($this->currentPageNumber + 1);
|
||||
}
|
||||
|
||||
public function hasPage($number)
|
||||
public function hasPage($number): bool
|
||||
{
|
||||
if (0 === $this->totalItems) {
|
||||
return 1 === $number;
|
||||
@@ -226,18 +222,18 @@ class Paginator implements PaginatorInterface
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPreviousPage()
|
||||
public function hasPreviousPage(): bool
|
||||
{
|
||||
return $this->hasPage($this->currentPageNumber - 1);
|
||||
}
|
||||
|
||||
public function isCurrentPage(PageInterface $page)
|
||||
public function isCurrentPage(PageInterface $page): bool
|
||||
{
|
||||
return $page->getNumber() === $this->currentPageNumber;
|
||||
}
|
||||
|
||||
public function setItemsPerPage($itemPerPage)
|
||||
public function setItemsPerPage(int $itemsPerPage)
|
||||
{
|
||||
$this->itemPerPage = $itemPerPage;
|
||||
$this->itemPerPage = $itemsPerPage;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user