Skip to content

PHPStan documentation of wp_update_post() seems to be too restrictive  #55

Open
@manooweb

Description

@manooweb

Since wordpress-stubs 6.0.2 PHPstan triggers errors when we pass $args parameter as an object to wp_update_post() function as it's allowed.
https://github.com/WordPress/WordPress/blob/6.0.2/wp-includes/post.php#L4703-L4718

The issue is closer than @Chouby one, however it seems to us that the PHPStan documentation isn't correct in the wp_update_post() function case.

for example

$post = get_post( $post_id );
$post->post_status = 'draft';
wp_update_post( $post );

triggers

 ------ -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  178    Parameter #1 $postarr of function wp_update_post expects array{ID?: int, post_author?: int, post_date?: string, post_date_gmt?: string, post_content?: string, post_content_filtered?: string, post_title?: string, post_excerpt?: string, ...}, WP_Post given.
 ------ -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions