[wp-trac] [WordPress Trac] #64645: Docs: Add missing null to $post parameter types in PHPDoc

WordPress Trac noreply at wordpress.org
Sun Feb 15 21:39:05 UTC 2026


#64645: Docs: Add missing null to $post parameter types in PHPDoc
-------------------------+-----------------------------
 Reporter:  apermo       |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  docs         |
-------------------------+-----------------------------
 Several functions across core accept `null` as a valid value for their
 `$post` parameter (defaulting to `null` in the function signature), but
 the corresponding `@param` type annotation does not include `null`.

 This causes incorrect type information for IDEs, static analysis tools
 (PHPStan), and developer documentation.

 Affected functions (all have `$post = null` in their signature):

   - `get_the_date()`, `get_the_modified_date()`, `get_the_time()`,
 `get_post_time()`, `get_post_datetime()`, `get_the_modified_time()`,
 `get_post_modified_time()`, `get_post_timestamp()` (general-template.php)
   - `_get_comment_reply_id()` (comment-template.php)
   - `get_post_embed_url()`, `get_post_embed_html()` (embed.php)
   - `get_post_mime_type()` (post.php)
   - `get_the_excerpt()`, `post_class()`, `get_post_class()`,
 `get_page_template_slug()` (post-template.php)
   - `has_category()`, `has_tag()`, `has_term()` (category-template.php)
   - `_update_posts_count_on_transition_post_status()` (ms-blogs.php)
   - `display_media_state()` (class-wp-widget-media.php)

 Additionally, `wp_force_plain_post_permalink()` uses `WP_Post|int|null`
 instead of the conventional `int|WP_Post|null` ordering.

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


More information about the wp-trac mailing list