Skip to content

Conversation

@huzaifaalmesbah
Copy link
Member

@huzaifaalmesbah huzaifaalmesbah commented Nov 17, 2025

Description

Fixes https://core.trac.wordpress.org/ticket/64262

Updates @return tag documentation to comply with WordPress PHP Documentation Standards.

Changes:

  • Replace boolean/Boolean with bool
  • Replace integer/Integer with int
  • Add descriptions to @return tags (type + description required)

Files: 10 files, 29 functions

  • wp-includes: class-wp-theme-json-resolver.php, block-supports/elements.php, formatting.php, comment.php, functions.php
  • wp-admin/includes: plugin.php, widgets.php, user.php, upgrade.php

Example:

// Before
@return integer|null

// After
@return int|null
// Before
@return string

// After  
@return string The base name of the given path.

Testing:

  • Documentation-only changes
  • No functional code modifications
  • Complies with WordPress Coding Standards

Drafted commit message

Docs: Add missing descriptions and fix types for some @return tags.

Props huzaifaalmesbah, sabernhardt, westonruter.
See #64224.
Fixes #64262.

Updates @return tag documentation across WordPress core to comply with the WordPress PHP Documentation Standards.

Changes:
- Replace boolean/Boolean with bool
- Replace integer/Integer with int
- Add descriptions to @return tags missing them

Fixes #64262
@github-actions
Copy link

github-actions bot commented Nov 17, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props huzaifaalmesbah, westonruter, sabernhardt.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Member

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.

@huzaifaalmesbah
Copy link
Member Author

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-includes/class-json.php as advised since it's a third-party library and deprecated.

*
* @param int $user_id User ID.
* @return array
* @return array Array of the user's draft posts.
Copy link
Member

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.

Copy link
Member

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.

*
* @param string $text
* @return string
* @return string Modified email text.
Copy link
Member

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."

*
* @param array $params
* @return array
* @return array Modified params 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'll change this to "Widget control arguments." as the function's description is "Retrieves the widget control arguments."

*
* @param array $sidebar_args
* @return array
* @return array Updated sidebar args array.
Copy link
Member

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."

Copy link
Member

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.

*
* @param string $tag_name
* @return string
* @return string Escaped tag name.
Copy link
Member

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.

Copy link
Member

@westonruter westonruter left a 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.

@huzaifaalmesbah
Copy link
Member Author

Thanks for the updates @westonruter The docs feel a lot clearer and more helpful now.

@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61270
GitHub commit: 33c8d7e

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants