Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/public/AppFramework/Db/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* @psalm-consistent-constructor
*/
abstract class Entity {
public int|string|null $id = null;
/** @var int $id */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure but maybe it makes sense to adjust the the variable doc to /** @var int|string|null $id */ for psalm's indication at other places in the server repo since the other adjustments were made according to that

public $id;
private array $_updatedFields = [];
/** @psalm-param $_fieldTypes array<string, Types::*> */
protected array $_fieldTypes = ['id' => 'integer'];
Expand Down
3 changes: 2 additions & 1 deletion lib/public/AppFramework/Db/SnowflakeAwareEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function setId($id): void {
*/
public function generateId(): void {
if ($this->id === null) {
/** @psalm-suppress InvalidPropertyAssignmentValue */
$this->id = Server::get(ISnowflakeGenerator::class)->nextId();
$this->markFieldUpdated('id');
}
Expand All @@ -50,7 +51,7 @@ public function getSnowflake(): ?Snowflake {
}

if ($this->snowflake === null) {
$this->snowflake = Server::get(ISnowflakeDecoder::class)->decode($this->id);
$this->snowflake = Server::get(ISnowflakeDecoder::class)->decode($this->getId());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have an explicit getId() in this entity which has the full return type?

}

return $this->snowflake;
Expand Down
Loading