Skip to content
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

Make it possible to strong type Entity properties #37209

Closed
wants to merge 4 commits into from

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented Mar 14, 2023

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-nc come-nc added this to the Nextcloud 27 milestone Mar 14, 2023
@come-nc come-nc self-assigned this Mar 14, 2023
@come-nc come-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, icewind1991, blizzz and artonge and removed request for a team March 15, 2023 12:57
This was referenced May 3, 2023
@@ -29,16 +29,16 @@
use function substr;

/**
* @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
Contributor Author

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
Contributor Author

come-nc commented May 15, 2023

/rebase

@come-nc come-nc force-pushed the fix/type-entity-properties branch from 4fce81e to 34d2622 Compare May 15, 2023 09:21
@come-nc come-nc modified the milestones: Nextcloud 27, Nextcloud 28 May 15, 2023
@szaimen szaimen 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-nc force-pushed the fix/type-entity-properties branch from 34d2622 to f7a61ac Compare June 26, 2023 13:58
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@skjnldsv skjnldsv mentioned this pull request Nov 1, 2023
@blizzz blizzz mentioned this pull request Nov 6, 2023
@come-nc come-nc modified the milestones: Nextcloud 28, Nextcloud 29 Nov 7, 2023
@Altahrim Altahrim mentioned this pull request Mar 12, 2024
@come-nc
Copy link
Contributor Author

come-nc commented Mar 12, 2024

Giving up on this one 😢

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

Successfully merging this pull request may close these issues.

5 participants