-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
refactor(entity): Don't type id #57442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'); | ||
| } | ||
|
|
@@ -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()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work unless we add a https://www.php.net/manual/en/class.returntypewillchange.php, but not sure this is worth it |
||
| } | ||
|
|
||
| return $this->snowflake; | ||
|
|
||
There was a problem hiding this comment.
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 thatThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately that breaks psalm for existing apps