[wp-trac] [WordPress Trac] #64813: Docs: Fix `@param` type for `get_posts()` and other functions using `wp_parse_args()`
WordPress Trac
noreply at wordpress.org
Mon Mar 16 17:14:28 UTC 2026
#64813: Docs: Fix `@param` type for `get_posts()` and other functions using
`wp_parse_args()`
-------------------------------------------------+-------------------------
Reporter: rodrigosprimo | Owner:
| rodrigosprimo
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 7.0
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: has-patch changes-requested needs- | Focuses: docs
unit-tests |
-------------------------------------------------+-------------------------
Comment (by rodrigosprimo):
Thanks for the explanation, @westonruter. I understand the reasoning
behind the conservative approach, and I'm happy to proceed that way.
I'll note that I believe that `@param` types should precisely describe
what the code actually accepts, since a mismatch between what the docs say
and what the code does can undermine trust in the documentation. That's
actually what prompted me to create this ticket when at first I thought
`get_posts()` only accepted an array and then realized it also accepts a
string (and an object). And if we don't want to encourage a given
behavior, like passing an object to `get_posts()`, I think the ideal
approach would be to explicitly deprecate it rather than leave it
undocumented. But I understand that's more time-consuming and probably not
a priority here.
In any case, I'm on board with keeping this limited to `array|string` for
`get_posts()`.
I pushed a commit to the PR adding a test for passing a query string to
`get_posts()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64813#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list