From 015797e4650be7b9b572fce0165f3b5c971e55d8 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:05:58 +0700 Subject: [PATCH] fix: `PrecountingStrategy` now accepts null as the underlying data --- CHANGELOG.md | 6 +++++- .../collections-common/src/Count/PrecountingStrategy.php | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e33a5c..95b4883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 0.11.0 +## 0.11.2 + +* fix: `PrecountingStrategy` now accepts null as the underlying data + +## 0.11.1 * docs: update readme * feat: offset pagination support diff --git a/packages/collections-common/src/Count/PrecountingStrategy.php b/packages/collections-common/src/Count/PrecountingStrategy.php index dc89843..76e4301 100644 --- a/packages/collections-common/src/Count/PrecountingStrategy.php +++ b/packages/collections-common/src/Count/PrecountingStrategy.php @@ -16,16 +16,16 @@ class PrecountingStrategy implements CountStrategy { /** - * @param int<0,max> $count + * @param ?int<0,max> $count */ - public function __construct(private int &$count) + public function __construct(private ?int &$count) { } #[\Override] public function getCount(?\Countable $underlyingObject): int { - return $this->count; + return $this->count ?? 0; } #[\Override]