Skip to content

Conversation

@CarlSchwan
Copy link
Member

  • Resolves: #

Summary

Some apps overwrite this and this breaks them.

TODO

  • ...

Checklist

Some apps overwrite this and this breaks them.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
@CarlSchwan CarlSchwan added this to the Nextcloud 33 milestone Jan 9, 2026
@CarlSchwan CarlSchwan self-assigned this Jan 9, 2026
@CarlSchwan CarlSchwan requested a review from a team as a code owner January 9, 2026 09:20
@CarlSchwan CarlSchwan added the 3. to review Waiting for reviews label Jan 9, 2026
@CarlSchwan CarlSchwan requested review from ArtificialOwl, come-nc, icewind1991 and leftybournes and removed request for a team January 9, 2026 09:20
@nextcloud-bot nextcloud-bot mentioned this pull request Jan 9, 2026
Copy link
Contributor

@kyteinsky kyteinsky left a comment

Choose a reason for hiding this comment

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

no error now 🚀

*/
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

Copy link
Member Author

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


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?

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

It is not just that apps may overwrite it but that they use $ob->id on entities for tables that don't use snowflakes. That creates a "viral" change that all APIs consuming the id need to be adapted or that we have to add checks to make Psalm happy.

@ChristophWurst ChristophWurst added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jan 12, 2026
@Altahrim Altahrim merged commit bd90e7c into master Jan 12, 2026
222 of 243 checks passed
@Altahrim Altahrim deleted the carl/entity-id-type branch January 12, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants