From fbc4bab2325abf74a7fa257e6f550b198fa97263 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 12 Nov 2026 23:48:43 +0100 Subject: [PATCH 1/2] Add the update guide for 5.0 Several 5.0 changes need an entry in the update guide; adding the empty guide first keeps their pull requests from conflicting over its creation. Co-Authored-By: Claude Opus 5.5 --- docs/index.md | 1 + docs/v4-to-v5-update.md | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 docs/v4-to-v5-update.md diff --git a/docs/index.md b/docs/index.md index 656c20a5..40c23df3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,3 +2,4 @@ * [Updating from v1 to v2](v1-to-v2-update.md) * [Updating from v2 to v3](v2-to-v3-update.md) * [Updating from v3 to v4](v3-to-v4-update.md) +* [Updating from v4 to v5](v4-to-v5-update.md) diff --git a/docs/v4-to-v5-update.md b/docs/v4-to-v5-update.md new file mode 100644 index 00000000..68e9b2d5 --- /dev/null +++ b/docs/v4-to-v5-update.md @@ -0,0 +1,3 @@ +## Updating from v4 to v5 + +The following changes were made to the Database package between v4 and v5. From 71b08ad5fd65e0561bd0d49d0b55bfe014c53ba9 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 13 Nov 2026 09:09:43 +0100 Subject: [PATCH 2/2] Declare native return types on DatabaseIterator The Iterator and Countable methods relied on #[\ReturnTypeWillChange], which only defers PHP's tentative return type errors. They now declare the interface return types. Co-Authored-By: Claude Opus 5.5 --- docs/v4-to-v5-update.md | 6 ++++++ src/DatabaseIterator.php | 18 ++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/v4-to-v5-update.md b/docs/v4-to-v5-update.md index 68e9b2d5..77a831cb 100644 --- a/docs/v4-to-v5-update.md +++ b/docs/v4-to-v5-update.md @@ -1,3 +1,9 @@ ## Updating from v4 to v5 The following changes were made to the Database package between v4 and v5. + +### `DatabaseIterator` has native return types + +`DatabaseIterator::count()`, `current()`, `key()`, `next()`, `rewind()` and `valid()` declare the return types of +`Iterator` and `Countable` (`int`, `mixed`, `mixed`, `void`, `void`, `bool`) instead of relying on +`#[\ReturnTypeWillChange]`. Subclasses that override these methods must declare the same return types. diff --git a/src/DatabaseIterator.php b/src/DatabaseIterator.php index 447c3bb9..5dd0b5e3 100644 --- a/src/DatabaseIterator.php +++ b/src/DatabaseIterator.php @@ -118,8 +118,7 @@ public function __destruct() * @see Countable::count() * @since 1.0 */ - #[\ReturnTypeWillChange] - public function count() + public function count(): int { if ($this->statement) { return $this->statement->rowCount(); @@ -136,8 +135,7 @@ public function count() * @see Iterator::current() * @since 1.0 */ - #[\ReturnTypeWillChange] - public function current() + public function current(): mixed { return $this->current; } @@ -150,8 +148,7 @@ public function current() * @see Iterator::key() * @since 1.0 */ - #[\ReturnTypeWillChange] - public function key() + public function key(): mixed { return $this->key; } @@ -164,8 +161,7 @@ public function key() * @see Iterator::next() * @since 1.0 */ - #[\ReturnTypeWillChange] - public function next() + public function next(): void { // Set the default key as being the number of fetched object $this->key = $this->fetched; @@ -195,8 +191,7 @@ public function next() * @see Iterator::rewind() * @since 1.0 */ - #[\ReturnTypeWillChange] - public function rewind() + public function rewind(): void { } @@ -208,8 +203,7 @@ public function rewind() * @see Iterator::valid() * @since 1.0 */ - #[\ReturnTypeWillChange] - public function valid() + public function valid(): bool { return (bool) $this->current; }