Opened 5 months ago
Closed 2 days ago
#64896 closed task (blessed) (fixed)
Docblock improvements for 7.1
| Reported by: | desrosj | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests dev-reviewed |
| Cc: | Focuses: | coding-standards |
Description
Previously:
- #64224 (7.0)
- #63166 (6.9)
- #62281 (6.8)
- #61608 (6.7)
- #60699 (6.6)
- #59651 (6.5)
- #58833 (6.4)
- #57840 (6.3)
- #56792 (6.2)
- #55646 (6.1)
- #54729 (6.0)
- #53399 (5.9)
- #52628 (5.8)
- #51800 (5.7)
- #50768 (5.6)
- #49572 (5.5)
- #48303 (5.4)
- #47110 (5.3)
- #46543 (5.2)
- #42505 (5.1)
- #41017 (4.9)
- #39130 (4.8)
- #37770 (4.7)
- #32246 (4.6)
Change History (74)
This ticket was mentioned in PR #11676 on WordPress/wordpress-develop by @shreyasikhar26.
4 months ago
#1
- Keywords has-patch added
This ticket was mentioned in PR #11678 on WordPress/wordpress-develop by @shreyasikhar26.
4 months ago
#2
- Keywords has-unit-tests added
This ticket was mentioned in PR #11087 on WordPress/wordpress-develop by @noruzzaman.
3 months ago
#5
Trac Ticket: https://core.trac.wordpress.org/ticket/64896
Why this change?
This aligns the codebase with the WordPress PHP Documentation Standards, ensuring that global variables used within functions are properly documented for better static analysis and code clarity.
Missing Tags: Added missing @global, @param, and @return descriptions.
Method Summaries: Added summaries for several methods in both list table classes that were previously undocumented.
Property Docs: Added DocBlocks for class properties ($order, $orderby, etc.).
This ticket was mentioned in PR #12043 on WordPress/wordpress-develop by @jonsurrell.
3 months ago
#7
Apply many documentation fixes across the HTML API. Changes include a wide range of issues from typos, mistakes, punctuation, grammar, and simple inaccuracies.
AI discovered and implemented corrections. All changes have been reviewed by me.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude (primary). Codex and GitHub Copilot for review.
Used for: Detecting and applying corrections. Review.
This ticket was mentioned in PR #10989 on WordPress/wordpress-develop by @huzaifaalmesbah.
3 months ago
#8
This patch improves the PHPDoc docblocks in WP_List_Table and WP_Plugins_List_Table for accuracy, completeness, and consistency with WordPress core documentation standards.
Trac:
https://core.trac.wordpress.org/ticket/64896
https://core.trac.wordpress.org/ticket/64224
@westonruter commented on PR #10989:
2 months ago
#10
Committed in r62491 (46f3c09)
@jonsurrell commented on PR #12043:
2 months ago
#12
Merged in r62507.
This ticket was mentioned in PR #12207 on WordPress/wordpress-develop by @jonsurrell.
2 months ago
#13
Updates some language in the documentation from r62507 to use clear technical language.
"Dangerous characters" is an unclear term, while HTML syntax characters is clear and precise. This was intended to be updated before landing https://github.com/WordPress/wordpress-develop/pull/12043 but was overlooked.
Follow-up to r62507.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
## Use of AI Tools
@jonsurrell commented on PR #12207:
2 months ago
#15
Committed in r62519.
This ticket was mentioned in PR #12251 on WordPress/wordpress-develop by @shailu25.
2 months ago
#16
Trac ticket: #64896
### Why this change?
- Updated Inline Documentation Order According to PHP Coding Standards
- Added
@seetag before@paramtag in Below files:
src/wp-includes/author-template.phpsrc/wp-includes/customize/class-wp-customize-nav-menu-setting.php
- Added
@globaltag after@seetag in Below files:
src/wp-includes/post.phpsrc/wp-includes/taxonomy.php
- Added
@deprecatedtag after@sincetag in Below file:
src/wp-includes/interactivity-api/class-wp-interactivity-api.php
## Use of AI Tools
- None
@shailu25 commented on PR #12251:
8 weeks ago
#17
The suggested changes have been applied.
This ticket was mentioned in PR #12269 on WordPress/wordpress-develop by @jonsurrell.
8 weeks ago
#18
The preferred way for users to iterate through an HTML document with the HTML Processor is via the methods ::next_tag() or ::next_token(). ::step() remains a public method, but is a discouraged interface.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
@jonsurrell commented on PR #12269:
7 weeks ago
#20
Merged in r62594.
This ticket was mentioned in PR #12440 on WordPress/wordpress-develop by @johnbillion.
6 weeks ago
#23
Follow-up to https://core.trac.wordpress.org/changeset/62332
This ticket was mentioned in PR #12441 on WordPress/wordpress-develop by @johnbillion.
6 weeks ago
#24
This adds a WP_Hook_Callback PHPStan type to represent the shape of a callback used internally in WP_Hook and used in return values of array access methods.
Also narrows a few other documented types.
@westonruter commented on PR #12441:
6 weeks ago
#25
I was looking into the other PHPStan rule level 10 issues in this file, and I found something related to the change you made here. It seems the offsetSet() method is lacking the use of the new type. I tried adding it:
--- a/src/wp-includes/class-wp-hook.php +++ b/src/wp-includes/class-wp-hook.php * * @param mixed $offset The offset to assign the value to. * @param mixed $value The value to set. + * + * @phpstan-param array-key|null $offset + * @phpstan-param array<string, Hook_Callback> $value */ #[ReturnTypeWillChange] public function offsetSet( $offset, $value ) {
But there are two errors remaining here:
At:
phpstan: Property WP_Hook::$callbacks (array<int, array<string, array{function: callable(): mixed, accepted_args: int}>>) does not accept non-empty-array<int|string, array<string, array{function: callable(): mixed, accepted_args: int}>>.
And at:
phpstan: Property WP_Hook::$priorities (list<int>) does not accept non-empty-list<int|string>.
@westonruter commented on PR #12441:
6 weeks ago
#26
Addressed in 67f3a9b.
This ticket was mentioned in PR #12443 on WordPress/wordpress-develop by @westonruter.
6 weeks ago
#27
This is stacked on #12441 and includes all of its commits. The only new commit here is b0d8b59476, which resolves the remaining PHPStan level 10 errors in WP_Hook on top of the type tightening done in that PR. @johnbillion: feel free to merge this into your branch if you want to fold it in; otherwise I'll rebase onto trunk once your PR lands.
The new commit:
- Adds the
Iterator/ArrayAccessgenerics via@phpstan-implements(already pushed to #12441) and@return voidto the methods lacking return values. - Documents the callback
$argsarrays aslist<mixed>and narrows the$callbackparams ofremove_filter()/has_filter()tocallable, matchingadd_filter(). - Passes
0instead offalseto_wp_filter_build_unique_id()inhas_filter(), matching itsint $priorityparam. (The value is unused for the key, so this is behavior-neutral.) - Restructures the
apply_filters()loop to assign the current priority to a local variable before storing it in$current_priority, bailing from the loop in the (impossible) case thatcurrent()returnsfalse. This keeps$current_priorityhonestly typed asarray<int, int>; previously, PHPStan sawint|falsebeing stored.
With this, vendor/bin/phpstan analyse src/wp-includes/class-wp-hook.php reports no errors at level 10.
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5
Used for: Diagnosing the PHPStan level 10 errors and drafting the fixes in the final commit; I reviewed, adjusted, and take responsibility for the changes.
---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code
@westonruter commented on PR #12441:
6 weeks ago
#28
I've followed up with https://github.com/WordPress/wordpress-develop/pull/12443 to add https://github.com/WordPress/wordpress-develop/pull/12443/changes/b0d8b59476800f371ed7b52016bc8ec0b4d752d8 which fixes the remaining PHPStan level 10 errors in class-wp-hooks.php. If you don't want to include those fixes in your commit here, I can commit it separately.
@noruzzaman commented on PR #11087:
6 weeks ago
#29
@noruzzamans This PR has merge conflicts with trunk. Could you please rebase/update the branch and resolve the conflicts?
Thanks @huzaifaalmesbah . I have resolved these conflicts. Please review it and let me know if need any improvement.
@SergeyBiryukov commented on PR #12443:
5 weeks ago
#30
The new commit:
- Adds
@return voidto the methods lacking return values.
As per the documentation standards, this should generally be avoided:
Note:
@return voidshould not be used outside the default bundled themes and the PHP compatibility shims included in WordPress Core.
That said, it is quite possible that this point is now outdated and should perhaps be reconsidered.
@westonruter commented on PR #12443:
5 weeks ago
#31
@SergeyBiryukov:
That said, it is quite possible that this point is now outdated and should perhaps be reconsidered.
I think it is obsolete, yes. PHPStan identifies the lack of a return type as an error. New void-returning functions being introduced in core have been using the native void type hint. That said, we could configure PHPStan to ignore the missing return type, but why? Better to be explicit.
Related: There has been cases of void being used in core already which have been replaced with null in unions via Core-64704.
@johnbillion commented on PR #12441:
5 weeks ago
#35
@johnbillion commented on PR #12443:
5 weeks ago
#36
I agree that refraining from using @return void is outdated, but let's handle that separately from these changes.
@westonruter commented on PR #12443:
5 weeks ago
#38
I agree that refraining from using
@return voidis outdated, but let's handle that separately from these changes.
Reverted in 199b9ce
This ticket was mentioned in PR #10804 on WordPress/wordpress-develop by @huzaifaalmesbah.
5 weeks ago
#39
Trac Ticket:
https://core.trac.wordpress.org/ticket/64896
https://core.trac.wordpress.org/ticket/64224
## Why this change?
This change aligns the codebase with the WordPress PHP Documentation Standards, which clearly distinguish between the intended usage of the @see and @link tags:
@seeis meant for referencing internal structural elements of the WordPress codebase, such as classes, functions, methods, or hooks.@linkis meant for referencing external resources, including URLs, specifications, and tickets hosted outside the codebase.
Currently, there are several instances in WordPress core where @see is incorrectly used to reference:
- GitHub URLs
- Trac tickets
- External specifications (e.g. WHATWG specs)
This PR corrects those cases by replacing @see with @link where the reference points to an external resource.
## When to use @link
- External URLs
Always use
@linkwhen referencing an external URL Example:@link https://html.spec.whatwg.org
- External resources
Use
@linkfor documentation, specifications, or tickets that live outside the WordPress codebase
## Contrast with @see
- Internal structure references
Use
@seewhen referring to:- Functions (e.g.
@see wp_remote_get()) - Classes (e.g.
@see WP_Query) - Methods or hooks defined within WordPress core
- Functions (e.g.
## Detailed changes
This PR applies targeted fixes across 15 specific files in src/wp-admin and src/wp-includes, replacing incorrect @see tags with @link where appropriate.
### src/wp-admin
edit-form-blocks.phpsite-editor.php
### src/wp-includes
html-api/class-wp-html-active-formatting-elements.phphtml-api/class-wp-html-doctype-info.phphtml-api/class-wp-html-tag-processor.phphtml-api/class-wp-html-decoder.phpclass-wp-url-pattern-prefixer.phpnav-menu-template.phppluggable.phpmedia.phprest-api/endpoints/class-wp-rest-controller.phprest-api/endpoints/class-wp-rest-templates-controller.phpscript-loader.phpspeculative-loading.phpdeprecated.php
@huzaifaalmesbah commented on PR #10804:
5 weeks ago
#40
Thanks for the review @westonruter ! Both points are now addressed:
- Merge conflicts have been resolved.
- The
@see→@linkchange has been applied to all WordPress core PHP occurrences. Bundled libraries were excluded.
This ticket was mentioned in PR #12681 on WordPress/wordpress-develop by @mukesh27.
3 weeks ago
#41
Trac ticket: https://core.trac.wordpress.org/ticket/64896
While working on #12680 found this typo issue.
Correct If black to If blank in the inline comment describing the optional RSS widget title handling. Longstanding typo, comment-only, no functional change.
## Use of AI Tools
N/A
@wildworks commented on PR #12681:
3 weeks ago
#43
Oops, it looks like this PR has already been committed. https://core.trac.wordpress.org/changeset/62849
@shailu25 commented on PR #12251:
2 weeks ago
#47
Merged Branch with Latest Trunk.
This ticket was mentioned in PR #12791 on WordPress/wordpress-develop by @bejignesh.
2 weeks ago
#48
WP_Duotone::is_preset() carries two @param tags for the same variable, giving contradictory types, and documents no return value at all:
* @param string $duotone_attr The duotone attribute from a block. * @param string|string[] $duotone_attr The duotone attribute from a block. */ private static function is_preset( $duotone_attr ) {
In [61603] the type was widened from string to string|string[], but the new tag replaced the @return line rather than the old @param:
- * @return bool True if the duotone preset present and valid. + * @param string|string[] $duotone_attr The duotone attribute from a block.
So the method lost its return documentation and kept a stale parameter type in the same edit.
## Fix
Drop the stale @param and restore the @return. The wording is the one [61603] removed, so nothing here is invented. Two independent references confirm it:
WP_Duotone::get_slug_from_attribute(), immediately above, was updated by that same changeset and got it right:@param string|string[]and a@return.- The Gutenberg counterpart,
lib/class-wp-duotone-gutenberg.php, still reads@param string|string[] $duotone_attrand@return bool True if the duotone preset present and valid.
string|string[] is the correct type. The method guards with ! is_string( $duotone_attr ) and returns false, which is exactly the array case [61603] was written to handle.
No functional change. phpcs passes on the file.
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Scanning src/ for docblock and signature disagreements, which is how this was found, and drafting this description. I confirmed the cause in the changeset history, checked the wording against the sibling method and the Gutenberg copy, ran phpcs, and I take responsibility for the change.
This ticket was mentioned in PR #12792 on WordPress/wordpress-develop by @bejignesh.
2 weeks ago
#49
Five functions in Twenty Nineteen and Twenty Twelve take arguments but have no @param tag at all, just a one line description.
Twenty Nineteen (inc/template-tags.php)
twentynineteen_get_user_avatar_markup( $id_or_email = null )twentynineteen_discussion_avatars_list( $comment_authors )twentynineteen_comment_form( $order )
Twenty Twelve (functions.php)
twentytwelve_page_menu_args( $args )twentytwelve_content_nav( $html_id )
The Twenty Twelve file documents parameters throughout, so those two stand out as gaps rather than a house style.
## Notes on the types
They come from the call sites, not from guesswork.
twentynineteen_comment_form() is documented as bool|string, because comments.php calls it three times, with 'desc', 'asc', and true. The body reads if ( true === $order || strtolower( $order ) === strtolower( get_option( 'comment_order', 'asc' ) ) ), so true forces display while a string only displays when it matches the option. The description says that rather than just listing the types.
twentynineteen_discussion_avatars_list() receives $discussion->authors, built in twentynineteen_get_discussion_data() as ( (int) $comment->user_id > 0 ) ? (int) $comment->user_id : $comment->comment_author_email, so entries are a user ID or an email address where there is no account.
twentynineteen_get_user_avatar_markup() passes its argument straight to get_avatar(), so it takes that function's wording for the accepted types. It also returns markup, so it gains a @return.
twentytwelve_page_menu_args() is a wp_page_menu_args filter callback and returns the array, so it gains a @return as well.
## What is deliberately not changed
No @since tags are added. The Twenty Nineteen file does not use them on functions, and adding them would mean guessing at versions. The two Twenty Twelve functions already have theirs.
No functional change. phpcs passes on both files.
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Scanning src/ for functions whose docblocks omit their parameters, which is how these were found, and drafting this description. I read each call site to confirm the types, ran phpcs, and I take responsibility for the change.
@mukesh27 commented on PR #12791:
2 weeks ago
#50
This was mistaken remove the @return and added duplicate in param https://core.trac.wordpress.org/ticket/64612 / [61603]
@wildworks commented on PR #12791:
2 weeks ago
#52
@bejignesh commented on PR #12792:
2 weeks ago
#53
@t-hamano this can be merged as well.
This ticket was mentioned in PR #12823 on WordPress/wordpress-develop by @bejignesh.
2 weeks ago
#54
Three core-owned methods are missing a @param tag.
WP_HTTP_IXR_Client::query()
The docblock already records that the ...$args parameter was formalized in 5.5.0 by adding it to the signature, but the parameter itself was never documented. WP_Dependency::__construct() carries the same @since wording and does document it as @param mixed ...$args Dependency information., so this brings the two back in line.
The description matches what the method does with the value: array_shift( $args ) takes the method name, and the remainder are the arguments passed to it.
WP_REST_Font_Collections_Controller::get_items_permissions_check()
Has @since and @return but no @param for $request.
WP_REST_Font_Families_Controller::get_endpoint_args_for_item_schema()
Has @since and @return but no @param for $method.
### Testing
--group xmlrpcpasses, 318 tests.- The font controller REST tests pass, 143 tests.
phpcsclean on all three files.php -lclean on all three files.
Documentation only, no behaviour change.
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Drafting the tags and this description. I confirmed each gap against the current file, checked the variadic wording against how core documents the same parameter on WP_Dependency::__construct(), verified the ...$args description against the method body, confirmed no existing ticket or pull request already covers these three, ran the xmlrpc and font REST tests plus phpcs, and I take responsibility for the result.
This ticket was mentioned in PR #12835 on WordPress/wordpress-develop by @Soean.
2 weeks ago
#55
## Description
remove_filter( $hook_name, $callback, $priority = 10 ) and remove_action( $hook_name, $callback, $priority = 10 ) take three parameters. A number of places in the PHPUnit test suite pass a fourth one, copied over from the matching add_filter()/add_action() call:
add_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 ); $exists = domain_exists( 'foo', 'bar' ); remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ), 10, 4 );
The fourth argument is silently ignored by PHP, but it is misleading: it suggests $accepted_args is part of the callback identity used to locate and unhook the callback, which it is not. Only the hook name, the callback and the priority are relevant.
This removes the superfluous argument throughout the test suite. Where the priority was the default 10, the now-redundant priority argument is dropped as well:
remove_filter( 'domain_exists', array( $this, 'domain_exists_cb' ) );
Non-default priorities are kept, since remove_filter() only finds a callback under the exact priority it was registered with:
remove_filter( 'pre_do_shortcode_tag', array( $this, 'filter_pre_do_shortcode_tag_attr' ), 12 );
No occurrences remain in src/, so this is a test-only change with no behavioural difference.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
@bejignesh commented on PR #12792:
12 days ago
#56
Feedback responded and it's all good now
This ticket was mentioned in PR #12924 on WordPress/wordpress-develop by @peterwilsoncc.
11 days ago
#57
A fix to the docblock annotation order to move @param below @global.
Follow up to https://github.com/WordPress/wordpress-develop/commit/5bf5b160c6c340e8cc29bf32ed254bc36990d1ef / r63065
This appears in all the branches it was backported to but I think it would be fine to commit this to trunk and the 7.0 branch. 7.1 too if this is not approved prior to branching.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
## Use of AI Tools
Nope.
@peterwilsoncc commented on PR #12924:
8 days ago
#58
Thanks @mukeshpanchal27, as WordPress 7.1 hasn't been branched, I'll need another committer to approve this prior to commit.
This was included in all the branches from the security fix but I think we can get away backporting to 7.0 upward as that will cover the currently supported release branch.
@peterwilsoncc commented on PR #12924:
6 days ago
#60
#61
@
6 days ago
I'd like to backport r63173 to the 7.1 branch and possibly the 7.0 branch in case it gets another minor release. Could I get an approval from another committer to do so (please be specific about whether it's for one or both branches)?
This ticket was mentioned in Slack in #core-committers by peterwilsoncc. View the logs.
6 days ago
#66
@
5 days ago
- Resolution → fixed
- Status new → closed
With RC3 due out today, I am going to close this out. That said, documentation changes are generally allowed at any point during the release cycle if they are necessary for the upcoming release. So this can be reopened if anything else is found that must be addressed prior to 7.1's final release.
I've opened #65860 for the 7.2 release cycle.
This ticket was mentioned in PR #13034 on WordPress/wordpress-develop by @jonsurrell.
4 days ago
#67
See https://github.com/WordPress/wporg-developer/pull/567 and https://github.com/WordPress/wporg-developer/pull/567.
This was discussed on the July 21 2026 dev chat and mentioned in a few relevant Slack channels (`#core` and `#docs`) and reception was positive.
Trac ticket: https://core.trac.wordpress.org/ticket/64896
## Use of AI Tools
None
#69
@
4 days ago
- Keywords dev-feedback added; dev-reviewed removed
- Resolution fixed
- Status closed → reopened
Are folks open to backporting r63293 to 7.1? It's a docs-only change. Reopening to consider the backport.
The reason it would be nice to include in 7.1 is so that the docs have a live example of the runnable code snippets. See the linked PR for the demo.
@jonsurrell commented on PR #13034:
4 days ago
#70
Merged in r63293.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I noticed that both #64717 and #64896 are tracking the same Docblock improvements for WordPress 7.1.
To avoid duplicate tracking, I think it would be better to keep one ticket as the main reference and close the other as a duplicate.