-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix(ros): Copy better typing information from Notifications/Spreed app #49192
fix(ros): Copy better typing information from Notifications/Spreed app #49192
Conversation
Signed-off-by: Joas Schilling <[email protected]>
@@ -11,6 +11,36 @@ | |||
/** | |||
* Class Validator | |||
* | |||
* @psalm-type RichObjectParameter = array{ |
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.
We could do this even better, by creating the exact types from
public $definitions = [ |
/**
* @psalm-type RichObjectParameterAddressbook = array{
* id: string,
* type: string,
* name: string,
* }
*
* @psalm-type RichObjectParameterAnnouncement = array{
* id: string,
* type: string,
* name: string,
* link?: string,
* }
*
* @psalm-type RichObjectParameter = RichObjectParameterAddressbook|RichObjectParameterAnnouncement
*/
Of course this would be with all types, not just these ones.
Then every consumer knows exactly what they can use, because even with this annotation psalm will not yet prevent you from adding keys that are for a different object type.
We could have a script for this to ensure the psalm types match the definitions and then also make it available as a type for OpenAPI.
Maybe this is a bit overkill
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.
Maybe this is a bit overkill
Glad you noticed it yourself :P
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.
Well I have written this exact logic for a different use-case already, so it's not completely out of reach, just wanted to mention it would be possible to make it even stricter.
Fixes failing Talk and Notification psalm in a better way than nextcloud/notifications@5cf07bd
Checklist