Skip to content

Commit 81a21fb

Browse files
committed
refactor(entity): Don't type id
Some apps overwrite this and this breaks them. Signed-off-by: Carl Schwan <carlschwan@kde.org>
1 parent 6fd76bf commit 81a21fb

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/public/AppFramework/Db/Entity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
* @psalm-consistent-constructor
2020
*/
2121
abstract class Entity {
22-
public int|string|null $id = null;
22+
/** @var int $id */
23+
public $id;
2324
private array $_updatedFields = [];
2425
/** @psalm-param $_fieldTypes array<string, Types::*> */
2526
protected array $_fieldTypes = ['id' => 'integer'];

lib/public/AppFramework/Db/SnowflakeAwareEntity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function setId($id): void {
3535
*/
3636
public function generateId(): void {
3737
if ($this->id === null) {
38+
/** @psalm-suppress InvalidPropertyAssignmentValue */
3839
$this->id = Server::get(ISnowflakeGenerator::class)->nextId();
3940
$this->markFieldUpdated('id');
4041
}
@@ -50,7 +51,7 @@ public function getSnowflake(): ?Snowflake {
5051
}
5152

5253
if ($this->snowflake === null) {
53-
$this->snowflake = Server::get(ISnowflakeDecoder::class)->decode($this->id);
54+
$this->snowflake = Server::get(ISnowflakeDecoder::class)->decode($this->getId());
5455
}
5556

5657
return $this->snowflake;

0 commit comments

Comments
 (0)