Build/Test Tools: Correct @var annotation in REST users controller tests - #12834
Build/Test Tools: Correct @var annotation in REST users controller tests#12834Soean wants to merge 1 commit into
@var annotation in REST users controller tests#12834Conversation
…tests. The `$query` variable in `test_get_items_only_fetches_ids_for_head_requests()` holds a `WP_User_Query` instance, as asserted by the preceding `assertInstanceOf()` call, not a `WP_User`. The incorrect annotation misleads static analysis and IDEs when resolving `$query->query_vars`.
|
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. |
What
Fixes an incorrect inline
@varannotation inWP_Test_REST_Users_Controller::test_get_items_only_fetches_ids_for_head_requests().The
$queryvariable comes from thepre_user_queryfilter args and is aWP_User_Queryinstance, theassertInstanceOf( WP_User_Query::class, ... )on the line above asserts exactly that. The docblock incorrectly declared it asWP_User.Why
WP_Userhas noquery_varsproperty, so the wrong annotation causes static analysis tools (PHPStan) and IDEs to report false errors on the following$query->query_varsaccesses, and it misleads anyone reading the testTrac ticket: https://core.trac.wordpress.org/ticket/64894
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.