You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your enhancement related to a problem? Please describe.
The Classifai\attachment_is_pdf() is currently declared as:
function attachment_is_pdf( \WP_Post$post ): bool
As the helper function is essentially a wrapper for get_post_mime_type(), it can accept either the post ID as an integer or a post object.
Within WordPress Core, most functions receiving a post as an argument accept either an ID or an integer, so it's intuitive for developers to reproduce this in plugins.
As the plugin supports PHP 7.4+, it's not possible to use a union type declaration introduced in PHP 8.0.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
Yes, this sounds like the right approach to me. As part of the refactoring done in #611, I added type declaration for all of our function arguments and return values. But any function that is hooked to WordPress could have potential problems here (a few of which we've already found and fixed), as sometimes WordPress accepts multiple argument types (and isn't always clear about this in the docblock) as well as anyone else could hook into this and return an unexpected value.
I had considered not adding type declaration to any function or method hooked to WordPress but for consistency sake, I decided to add it to everything. All that said, in this instance I think we should remove that and there may be other places we might want to consider doing the same. Feel free to open a PR to at least solve the attachment_is_pdf function but can also look at other areas if you're interested
Is your enhancement related to a problem? Please describe.
The
Classifai\attachment_is_pdf()
is currently declared as:As the helper function is essentially a wrapper for
get_post_mime_type()
, it can accept either the post ID as an integer or a post object.Within WordPress Core, most functions receiving a post as an argument accept either an ID or an integer, so it's intuitive for developers to reproduce this in plugins.
As the plugin supports PHP 7.4+, it's not possible to use a union type declaration introduced in PHP 8.0.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: