Skip to content

Make it possible to strong type Entity properties - #37209

Closed
come-nc wants to merge 4 commits into
masterfrom
fix/type-entity-properties
Closed

Make it possible to strong type Entity properties#37209
come-nc wants to merge 4 commits into
masterfrom
fix/type-entity-properties

Conversation

@come-nc

@come-nccome-nc commented Mar 14, 2023

Copy link
Copy Markdown
Contributor

PropertyNotSetInConstructor still have to be suppressed because properties are
actually set in fromRow/fromParams methods, and the init path is too
convoluted anyway.

  • Resolves: #

Summary

I tried several solutions to improve typing for QBMapper/Entity, I could not find a clean way to type properties without suppressing PropertyNotSetInConstructor manually and adding the @method annotations by hand as well.
But at least we can now type those properties and have psalm-compliant entities.
Also id property is actually nullable and null by default for autoincrement, made that clear in the code.

Checklist

@come-nccome-nc added 2. developing Work in progress technical debt 🧱 🤔🚀 labels Mar 14, 2023
@come-nccome-nc added this to the Nextcloud 27 milestone Mar 14, 2023
@come-nccome-nc self-assigned this Mar 14, 2023
Comment threadlib/private/Authentication/Token/PublicKeyToken.php Fixed
@come-nc
come-ncforce-pushed the fix/type-entity-properties branch from 7127218 to 739f2caCompareMarch 15, 2023 11:25
@come-nccome-nc added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Mar 15, 2023
@come-nc
come-nc requested review from a team, ArtificialOwl, artonge, blizzz and icewind1991 and removed request for a teamMarch 15, 2023 12:57
This was referenced May 3, 2023
Comment threadlib/private/Authentication/Token/IToken.php

/**
* @method int getId()
* @method ?int getId()

Check failure

Code scanning / Psalm

ImplementedReturnTypeMismatch

The inherited return type 'int' for OC\Authentication\Token\IToken::getId is different to the implemented return type for OC\Authentication\Token\PublicKeyToken::getid 'int|null'

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I do not understand this error, OC\Authentication\Token\PublicKeyToken::getId has a return type of int, not ?int.

@come-nc

Copy link
Copy Markdown
ContributorAuthor

/rebase

@come-nc
come-ncforce-pushed the fix/type-entity-properties branch from 4fce81e to 34d2622CompareMay 15, 2023 09:21
@szaimenszaimen added 2. developing Work in progress and removed 3. to review Waiting for reviews labels May 16, 2023
PropertyNotSetInConstructor still have to be suppressed because properties are
actually set in fromRow/fromParams methods, and the init path is too
convoluted anyway.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc
come-ncforce-pushed the fix/type-entity-properties branch from 34d2622 to f7a61acCompareJune 26, 2023 13:58
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@skjnldsvskjnldsv mentioned this pull request Nov 1, 2023
@blizzzblizzz mentioned this pull request Nov 6, 2023
@come-nccome-nc modified the milestones: Nextcloud 28, Nextcloud 29Nov 7, 2023
@AltahrimAltahrim mentioned this pull request Mar 12, 2024
@come-nc

Copy link
Copy Markdown
ContributorAuthor

Giving up on this one 😢

@come-nccome-nc closed this Mar 12, 2024
@skjnldsv
skjnldsv deleted the fix/type-entity-properties branch March 14, 2024 07:50
@skjnldsvskjnldsv removed this from the Nextcloud 29 milestone Aug 14, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developingWork in progresstechnical debt🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@come-nc@artonge@Pytal@github-advanced-security@skjnldsv@szaimen