Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented May 4, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? no
Deprecations? no
Issues Fix #60140 (comment)
License MIT

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 it contentMap in the payload instead

@xabbuh xabbuh requested a review from OskarStark as a code owner May 4, 2025 20:03
@carsonbot carsonbot added this to the 7.3 milestone May 4, 2025
@carsonbot carsonbot changed the title [Notifier] document the array shape of the content option [Notifier] document the array shape of the content option May 4, 2025
@xabbuh xabbuh added the ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" label May 5, 2025
@stof
Copy link
Member

stof commented May 5, 2025

AFAIK, this content option has nothing to do with the activitystreams specification of the W3C. It has to do with symfony/ux#1853

@stof
Copy link
Member

stof commented May 5, 2025

And this means that the type added in this PR is the wrong one.

@xabbuh
Copy link
Member Author

xabbuh commented May 8, 2025

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?

@stof
Copy link
Member

stof commented May 12, 2025

Looking at the typescript types, they actually refer to the options supported by the Notification constructor of the web platform: https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification#options

@xabbuh xabbuh force-pushed the pr-60140 branch 2 times, most recently from 9cba2a0 to 2b9721f Compare May 12, 2025 09:19
Comment on lines 82 to 95
* @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
Copy link
Member

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?

Copy link
Member

@stof stof May 13, 2025

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,
Copy link
Member

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[],
Copy link
Member

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)

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Notifier ❄️ Feature Freeze Important Pull Requests to finish before the next Symfony "feature freeze" Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants