[wp-trac] [WordPress Trac] #40481: Inline docs for wp_get_post_tags() and wp_get_post_terms() don't reflect possible return values

WordPress Trac noreply at wordpress.org
Wed Apr 19 10:45:29 UTC 2017


#40481: Inline docs for wp_get_post_tags() and wp_get_post_terms() don't reflect
possible return values
--------------------------+-----------------------------
 Reporter:  philipjohn    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.7.3
 Severity:  normal        |   Keywords:
  Focuses:  docs          |
--------------------------+-----------------------------
 It looks like the inline documentation for both `wp_get_post_tags()` and
 `wp_get_post_terms()` are missing possible return values, and some
 information on the nature of the possible return values.

 `wp_get_post_tags()` has the following as the inline doc comment for the
 return value:

 > array List of post tags.

 However, it might not return an array and while "list of post tags" is
 correct, that isn't entirely useful. The function will return an array of
 `WP_Term` objects, which is important information for a developer wanting
 to use the function.

 And while `wp_get_post_tags()` sets the `$taxonomy` parameter when calling
 `wp_get_post_terms()` it's possible to remove that taxonomy, making it
 possible for `wp_get_post_tags()` to return a `WP_Error` object.

 Similarly, `wp_get_post_terms()` uses "List of post terms or empty array"
 in it's inline docs on the return value. More useful is to know that it
 returns an array of `WP_Term` objects.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40481>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list