From 82ce166146312ee9848a53b1d0196448b12bff53 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Tue, 15 Sep 2026 13:59:58 +0200 Subject: [PATCH] Make RevisionableInterface::getRevision() nullable It's actually nullable in practice, so the non-nullable return type added in the PHP 8.3 modernization pass was wrong. Update the README example and UPGRADE-2.0.md accordingly. Co-Authored-By: Claude Sonnet 5 --- README.md | 2 +- UPGRADE-2.0.md | 2 +- src/RevisionableInterface.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6dc2859..fdaed8f 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ class MyEntity implements RevisionableInterface return $this; } - public function getRevision(): RevisionInterface + public function getRevision(): ?RevisionInterface { return $this->revision; } diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md index b484e4f..1638f82 100644 --- a/UPGRADE-2.0.md +++ b/UPGRADE-2.0.md @@ -15,7 +15,7 @@ UPGRADE FROM 1.x to 2.0 `RevisionFactoryInterface`. Any implementation of these interfaces must add matching return types: - `RevisionableInterface::setRevision()`: `static` (now fluent, must `return $this;`) - - `RevisionableInterface::getRevision()`: `RevisionInterface` + - `RevisionableInterface::getRevision()`: `?RevisionInterface` - `RevisionInterface::getUser()`: `?string` - `RevisionInterface::getCreatedAt()`: `\DateTimeInterface` - `RevisionFactoryInterface::createRevision()`: `RevisionInterface` (no longer diff --git a/src/RevisionableInterface.php b/src/RevisionableInterface.php index 7f63769..2eea3aa 100644 --- a/src/RevisionableInterface.php +++ b/src/RevisionableInterface.php @@ -14,7 +14,7 @@ interface RevisionableInterface public function setRevision(RevisionInterface $revision): static; /** - * Return the current revision + * Return the current revision, or null if there is none. */ - public function getRevision(): RevisionInterface; + public function getRevision(): ?RevisionInterface; }