Opened 11 months ago
Closed 11 months ago
#63802 closed defect (bug) (fixed)
Incorrect @return tag in doc comment for get_post_field()
| Reported by: | marian1 | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.9 |
| Component: | Posts, Post Types | Version: | |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: | docs |
Description
get_post_field() either returns an empty string or the sanitised post field value via sanitize_post_field().
Although the documented return type is string, the actual return value and type depend on the requested post field. For example, get_post_field('post_parent', $post_id) returns an integer value.
To align the documentation with the actual behaviour, I suggest updating the @return tag to either mixed (as documented for sanitize_post_field()) or specifying the union of all possible return types.
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Update
get_post_field()docblock to reflect actual return types(int|string|int[])instead of always string.Trac ticket: https://core.trac.wordpress.org/ticket/63802