[wp-trac] [WordPress Trac] #62366: get_post_states() throws PHP warning
WordPress Trac
noreply at wordpress.org
Tue Nov 19 12:10:39 UTC 2024
#62366: get_post_states() throws PHP warning
-------------------------+-------------------------------------------------
Reporter: akramipro | Owner: (none)
Type: defect | Status: new
(bug) |
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post | Version: 6.7
Types |
Severity: normal | Resolution:
Keywords: has-patch | Focuses: coding-standards, php-
| compatibility
-------------------------+-------------------------------------------------
Comment (by realloc):
The function might be updated with types in the future to make it clearer
and more reliable. Right now, it looks like this:
{{{#!php
<?php
/**
* Retrieves an array of post states from a post.
*
* @since 5.3.0
*
* @param WP_Post $post The post to retrieve states for.
* @return string[] Array of post state labels keyed by their state.
*/
function get_post_states( $post ) {}
}}}
If types are added to this function, it will become the caller's
responsibility to make sure the input is correct. This is why I think we
should not hide the error, as it helps us see and fix potential problems.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62366#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list