-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] document the array shape of the content option #60342
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
base: 7.3
Are you sure you want to change the base?
Conversation
AFAIK, this |
And this means that the type added in this PR is the wrong one. |
I have no idea how to read the code of the linked pull request in regard to the changes we want to do here. What would be the right array shape to use? |
Looking at the typescript types, they actually refer to the options supported by the |
9cba2a0
to
2b9721f
Compare
* @return array{ | ||
* actions?: array, | ||
* badge?: string, | ||
* body?: string, | ||
* data?: mixed, | ||
* dir?: 'auto'|'ltr'|'rtl', | ||
* icon?: string, | ||
* image?: string, | ||
* lang?: string, | ||
* renotify?: bool, | ||
* requireInteraction?: bool, | ||
* silent?: bool, | ||
* tag?: string, | ||
* timestamp?: int, | ||
* vibrate?: int[], | ||
* }|null |
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.
If it's strictly the same as the constructor, we could use local types aliases (https://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases) to avoid discrepancies if it's updated. What do you think?
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 don't use type aliases in the Symfony codebase AFAICT. They are less interoperable than the array shape syntax
@@ -22,6 +22,22 @@ final class MercureOptions implements MessageOptionsInterface | |||
|
|||
/** | |||
* @param string|string[]|null $topics | |||
* @param array{ | |||
* actions?: 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.
I would remove this one. https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification#actions says it can only be used for persistent notifications, so passing a value here would break things.
* silent?: bool, | ||
* tag?: string, | ||
* timestamp?: int, | ||
* vibrate?: int[], |
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.
should be list<int>
(if it is not a list, it won't be an Array in JS as JS Array is not the equivalent of a PHP array but is strictly a list)
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.
btw, according to https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API#concepts_and_usage, it should probably be int|list<int>
as passing a single number seems to be supported.
but I wonder: is it actually correct that
$content
is an array, according to https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content I would have guessed that it needs to be a string or (if it was an array), we would have to call itcontentMap
in the payload instead