-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(Comments): sort by id (not type+id) in getMentions #56162
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: master
Are you sure you want to change the base?
Conversation
Updated the docblock for the getMentions method to clarify its return value and sorting behavior. Signed-off-by: Josh <[email protected]>
Updated the getMentions method to inherit documentation and change sorting logic. Signed-off-by: Josh <[email protected]>
| /** | ||
| * returns an array containing mentions that are included in the comment | ||
| * | ||
| * @return array each mention provides a 'type' and an 'id', see example below | ||
| * @psalm-return list<array{type: 'guest'|'email'|'federated_group'|'group'|'federated_team'|'team'|'federated_user'|'user', id: non-empty-lowercase-string}> | ||
| * @since 30.0.2 Type 'email' is supported | ||
| * @since 29.0.0 Types 'federated_group', 'federated_team', 'team' and 'federated_user' are supported | ||
| * @since 23.0.0 Type 'group' is supported | ||
| * @since 17.0.0 Type 'guest' is supported | ||
| * @since 11.0.0 | ||
| * @inheritDoc | ||
| */ |
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 completely remove that block and add a #[Override] instead
| usort($result, static function ($mention1, $mention2) { | ||
| return mb_strlen($mention2['id']) <=> mb_strlen($mention1['id']); | ||
| }); |
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.
| usort($result, static function ($mention1, $mention2) { | |
| return mb_strlen($mention2['id']) <=> mb_strlen($mention1['id']); | |
| }); | |
| usort($result, static fn (array $mention1, array $mention2): int => mb_strlen($mention2['id']) <=> mb_strlen($mention1['id'])); |
While at it ;)
| * @return array Each mention is an associative array with 'type' and 'id' keys, sorted by descending length. | ||
| * @psalm-return list<array{type: 'guest'|'email'|'federated_group'|'group'|'federated_team'|'team'|'federated_user'|'user', id: non-empty-lowercase-string}> |
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.
| * @return array Each mention is an associative array with 'type' and 'id' keys, sorted by descending length. | |
| * @psalm-return list<array{type: 'guest'|'email'|'federated_group'|'group'|'federated_team'|'team'|'federated_user'|'user', id: non-empty-lowercase-string}> | |
| * @return list<array{type: 'guest'|'email'|'federated_group'|'group'|'federated_team'|'team'|'federated_user'|'user', id: non-empty-lowercase-string}> Each mention is an associative array with 'type' and 'id' keys, sorted by descending length. |
Merge the two @return annotation
| * @since 30.0.2 Type 'email' is supported | ||
| * @since 29.0.0 Types 'federated_group', 'federated_team', 'team' and 'federated_user' are supported | ||
| * @since 23.0.0 Type 'group' is supported | ||
| * @since 21.0.1 Sort returned results by |
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.
by what?
Summary
TODO
Checklist
3. to review, feature component)stable32)