-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Docs: Fix improper @return tag documentation to comply with WordPress standards #10522
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
Docs: Fix improper @return tag documentation to comply with WordPress standards #10522
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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.
This is a third-party library so I don't think it should have its coding standards updated. It will complicate future patches. Nevertheless, the file itself is deprecated, so I think it should be ignored.
Co-authored-by: Weston Ruter <[email protected]> Co-authored-by: Stephen A. Bernhardt <[email protected]>
|
Thanks @westonruter and @sabernhardt for your detailed reviews and helpful suggestions. I've applied all the recommended changes, and I’ve ignored updates to |
src/wp-admin/includes/user.php
Outdated
| * | ||
| * @param int $user_id User ID. | ||
| * @return array | ||
| * @return array Array of the user's draft posts. |
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.
When/if we adopt PHPStan types, it would be nice if this were typed as array<object{ ID: int, post_title: string }>. Right now it is not clear what the return value is supposed to be.
Nevertheless, this function is not even used in core anymore, so it might as well be moved to be deprecated.
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'm updating this to:
@return object[] The user's draft posts, with 'ID' and 'post_title' keys.
src/wp-admin/includes/user.php
Outdated
| * | ||
| * @param string $text | ||
| * @return string | ||
| * @return string Modified email text. |
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'm changing this to "User site invitation email message."
src/wp-admin/includes/widgets.php
Outdated
| * | ||
| * @param array $params | ||
| * @return array | ||
| * @return array Modified params 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'll change this to "Widget control arguments." as the function's description is "Retrieves the widget control arguments."
src/wp-admin/includes/widgets.php
Outdated
| * | ||
| * @param array $sidebar_args | ||
| * @return array | ||
| * @return array Updated sidebar args 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.
This doesn't look right. The supplied $sidebar_args is not modified in any way. It is just passed straight through. I'll change this to "Passed through value of $sidebar_args param."
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.
The return value is never read in core either. So it seems like it doesn't really need to have returned anything.
src/wp-includes/formatting.php
Outdated
| * | ||
| * @param string $tag_name | ||
| * @return string | ||
| * @return string Escaped tag name. |
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.
Technically “escaped” is incorrect here. It is actually sanitized. I'll update.
westonruter
left a comment
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 made some tweaks. Take a look.
|
Thanks for the updates @westonruter The docs feel a lot clearer and more helpful now. |
Description
Fixes https://core.trac.wordpress.org/ticket/64262
Updates
@returntag documentation to comply with WordPress PHP Documentation Standards.Changes:
boolean/Booleanwithboolinteger/Integerwithint@returntags (type + description required)Files: 10 files, 29 functions
class-wp-theme-json-resolver.php,block-supports/elements.php,formatting.php,comment.php,functions.phpplugin.php,widgets.php,user.php,upgrade.phpExample:
Testing:
Drafted commit message
Docs: Add missing descriptions and fix types for some
@returntags.Props huzaifaalmesbah, sabernhardt, westonruter.
See #64224.
Fixes #64262.