phpstan-wordpress
phpstan-wordpress copied to clipboard
Bad types into WP_Post class
Hi !
There are two bad copy/paste into WP_Post class :
/**
* ID of post author.
*
* A numeric string, for compatibility reasons.
*
* @since 3.5.0
* @var string
*/
public $post_author = 0;
// ...
/**
* Cached comment count.
*
* A numeric string, for compatibility reasons.
*
* @since 3.5.0
* @var string
*/
public $comment_count = 0;
For this two properties, the @var
should be int
Thanks a lot ! Flo
Hi @FlorientR 👋🏻 Thank you for your report.
WP core stubs are automatically generated.
https://github.com/WordPress/wordpress-develop/blob/6.1/src/wp-includes/class-wp-post.php#L32-L40
string
is there since 2015.
Please open a ticket in WordPress trac.
We have no mechanism to fix individual property types. Although you may invent one! PR-s are welcome 😍
These are indeed numeric strings, as mentioned in the inline doc right above the type.
😲
A numeric string, for compatibility reasons.
It's just occurred to me that the default value is the incorrect type:
public $post_author = 0;
I'll have a dig around in WordPress core and see if this can be fixed.