Skip to content

Commit

Permalink
[Pagerfanta] Defined int range for Notification total count
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Dec 27, 2024
1 parent 58f2bfb commit 71c4469
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/contracts/Persistence/Notification/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function loadUserNotifications(int $userId, int $offset, int $limit): arr
/**
* @param int $currentUserId
*
* @return int
* @phpstan-return int<0, max>
*/
public function countNotifications(int $currentUserId): int;

Expand Down
2 changes: 1 addition & 1 deletion src/contracts/Repository/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getPendingNotificationCount(): int;
/**
* Get count of total users notifications.
*
* @return int
* @phpstan-return int<0, max>
*/
public function getNotificationCount(): int;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
use IteratorAggregate;
use Traversable;

/**
* @implements \IteratorAggregate<int, \Ibexa\Contracts\Core\Repository\Values\Notification\Notification>
*/
class NotificationList extends ValueObject implements IteratorAggregate
{
/** @var int */
public $totalCount = 0;
/** @phpstan-var int<0, max> */
public int $totalCount = 0;

/** @var \Ibexa\Contracts\Core\Repository\Values\Notification\Notification[] */
public $items = [];
public array $items = [];

/**
* {@inheritdoc}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Persistence/Legacy/Notification/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract public function updateNotification(Notification $notification): void;
/**
* @param int $userId
*
* @return int
* @phpstan-return int<0, max>
*/
abstract public function countUserNotifications(int $userId): int;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ public function updateNotification(Notification $notification): void
$query->execute();
}

/**
* {@inheritdoc}
*/
public function countUserNotifications(int $userId): int
{
$query = $this->connection->createQueryBuilder();
Expand All @@ -111,7 +108,8 @@ public function countUserNotifications(int $userId): int
->where($query->expr()->eq(self::COLUMN_OWNER_ID, ':user_id'))
->setParameter(':user_id', $userId, PDO::PARAM_INT);

return (int)$query->execute()->fetchColumn();
/** @phpstan-var int<0, max> */
return (int)$query->execute()->fetchOne();
}

/**
Expand Down

0 comments on commit 71c4469

Please sign in to comment.