From 81a21fb71830c1d7340feea07c004deeb353ec6b Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 9 Jan 2026 10:19:34 +0100 Subject: [PATCH] refactor(entity): Don't type id Some apps overwrite this and this breaks them. Signed-off-by: Carl Schwan --- lib/public/AppFramework/Db/Entity.php | 3 ++- lib/public/AppFramework/Db/SnowflakeAwareEntity.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index f29eef92b28..886326ca0fc 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -19,7 +19,8 @@ use function substr; * @psalm-consistent-constructor */ abstract class Entity { - public int|string|null $id = null; + /** @var int $id */ + public $id; private array $_updatedFields = []; /** @psalm-param $_fieldTypes array */ protected array $_fieldTypes = ['id' => 'integer']; diff --git a/lib/public/AppFramework/Db/SnowflakeAwareEntity.php b/lib/public/AppFramework/Db/SnowflakeAwareEntity.php index bdcbf12135b..87c91e995b8 100644 --- a/lib/public/AppFramework/Db/SnowflakeAwareEntity.php +++ b/lib/public/AppFramework/Db/SnowflakeAwareEntity.php @@ -35,6 +35,7 @@ abstract class SnowflakeAwareEntity extends Entity { */ public function generateId(): void { if ($this->id === null) { + /** @psalm-suppress InvalidPropertyAssignmentValue */ $this->id = Server::get(ISnowflakeGenerator::class)->nextId(); $this->markFieldUpdated('id'); } @@ -50,7 +51,7 @@ abstract class SnowflakeAwareEntity extends Entity { } if ($this->snowflake === null) { - $this->snowflake = Server::get(ISnowflakeDecoder::class)->decode($this->id); + $this->snowflake = Server::get(ISnowflakeDecoder::class)->decode($this->getId()); } return $this->snowflake;