Add dynamic return type extension for get_post_types#177
Add dynamic return type extension for get_post_types#177lipemat wants to merge 2 commits intoszepeviktor:masterfrom lipemat:feature/get-post-types-extension
get_post_types#177Conversation
The `get_post_types` function return either and array of `string` or an array of `WP_Post_Type` depending on the passed arguments.
Account for different results from `get_post_types` based on the arguments passed. Also submitted a pull request upstream and simply keeping this here in case that does not get merged. @todo Remove this extension if the pull request gets merged and released upstream szepeviktor/phpstan-wordpress#177
|
Could it be done with the new conditional type in WP stubs? |
good point, looks like this would work: https://phpstan.org/r/6e188841-6faf-4de8-9c0f-57ebabc3e626 |
Tests are now included should you decide to use this code. :) |
|
Thank you for your work. |
|
The conditional thing then must work for |
|
@lipemat Conditional return types arrived in php-stubs/wordpress-stubs#73 Thank you for your PR!! |
|
I will use your tests. |
Introduce GetPostTypesDynamicFunctionReturnTypeExtension service
The
get_post_typesfunction return either and array ofstringor an array ofWP_Post_Typedepending on the passed arguments.https://developer.wordpress.org/reference/functions/get_post_types/#return