Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad types into WP_Post class #170

Open
FlorientR opened this issue Mar 9, 2023 · 4 comments
Open

Bad types into WP_Post class #170

FlorientR opened this issue Mar 9, 2023 · 4 comments

Comments

@FlorientR
Copy link

FlorientR commented Mar 9, 2023

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

@szepeviktor
Copy link
Owner

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 😍

@johnbillion
Copy link
Sponsor Contributor

These are indeed numeric strings, as mentioned in the inline doc right above the type.

@szepeviktor
Copy link
Owner

😲

A numeric string, for compatibility reasons.

@szepeviktor szepeviktor closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2023
@johnbillion
Copy link
Sponsor Contributor

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.

@szepeviktor szepeviktor reopened this Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants