Closed lipemat closed 1 year ago
Could it be done with the new conditional type in WP stubs? @phpstan-assert-if...
https://phpstan.org/writing-php-code/narrowing-types#custom-type-checking-functions-and-methods
Could it be done with the new conditional type in WP stubs?
@phpstan-assert-if...
https://phpstan.org/writing-php-code/narrowing-types#custom-type-checking-functions-and-methods
good point, looks like this would work: https://phpstan.org/r/6e188841-6faf-4de8-9c0f-57ebabc3e626
can you add a new file with assertion tests, please? an example would be e.g. #144
Tests are now included should you decide to use this code. :)
Thank you for your work. I am very sorry. That conditional thing, Martin wrote, makes PHPStan work alone. That should be added to WP stubs.
The conditional thing then must work for get_taxonomies()
as well.
@lipemat Conditional return types arrived in https://github.com/php-stubs/wordpress-stubs/pull/73
Thank you for your PR!!
I will use your tests.
tests/data/get_post_types.php
Introduce GetPostTypesDynamicFunctionReturnTypeExtension service
The
get_post_types
function return either and array ofstring
or an array ofWP_Post_Type
depending on the passed arguments.https://developer.wordpress.org/reference/functions/get_post_types/#return