Skip to content

Commit 71c4469

Browse files
committed
[Pagerfanta] Defined int range for Notification total count
1 parent 58f2bfb commit 71c4469

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

src/contracts/Persistence/Notification/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function loadUserNotifications(int $userId, int $offset, int $limit): arr
6262
/**
6363
* @param int $currentUserId
6464
*
65-
* @return int
65+
* @phpstan-return int<0, max>
6666
*/
6767
public function countNotifications(int $currentUserId): int;
6868

src/contracts/Repository/NotificationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getPendingNotificationCount(): int;
5959
/**
6060
* Get count of total users notifications.
6161
*
62-
* @return int
62+
* @phpstan-return int<0, max>
6363
*/
6464
public function getNotificationCount(): int;
6565

src/contracts/Repository/Values/Notification/NotificationList.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
use IteratorAggregate;
1414
use Traversable;
1515

16+
/**
17+
* @implements \IteratorAggregate<int, \Ibexa\Contracts\Core\Repository\Values\Notification\Notification>
18+
*/
1619
class NotificationList extends ValueObject implements IteratorAggregate
1720
{
18-
/** @var int */
19-
public $totalCount = 0;
21+
/** @phpstan-var int<0, max> */
22+
public int $totalCount = 0;
2023

2124
/** @var \Ibexa\Contracts\Core\Repository\Values\Notification\Notification[] */
22-
public $items = [];
25+
public array $items = [];
2326

2427
/**
2528
* {@inheritdoc}

src/lib/Persistence/Legacy/Notification/Gateway.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract public function updateNotification(Notification $notification): void;
4444
/**
4545
* @param int $userId
4646
*
47-
* @return int
47+
* @phpstan-return int<0, max>
4848
*/
4949
abstract public function countUserNotifications(int $userId): int;
5050

src/lib/Persistence/Legacy/Notification/Gateway/DoctrineDatabase.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ public function updateNotification(Notification $notification): void
9999
$query->execute();
100100
}
101101

102-
/**
103-
* {@inheritdoc}
104-
*/
105102
public function countUserNotifications(int $userId): int
106103
{
107104
$query = $this->connection->createQueryBuilder();
@@ -111,7 +108,8 @@ public function countUserNotifications(int $userId): int
111108
->where($query->expr()->eq(self::COLUMN_OWNER_ID, ':user_id'))
112109
->setParameter(':user_id', $userId, PDO::PARAM_INT);
113110

114-
return (int)$query->execute()->fetchColumn();
111+
/** @phpstan-var int<0, max> */
112+
return (int)$query->execute()->fetchOne();
115113
}
116114

117115
/**

0 commit comments

Comments
 (0)