diff --git a/functionMap.php b/functionMap.php index 47a4c29..3c5063a 100644 --- a/functionMap.php +++ b/functionMap.php @@ -2,7 +2,7 @@ declare(strict_types=1); -$httpReturnType = 'array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error'; +$httpReturnType = 'array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error'; if (file_exists(sprintf('%s/source/wordpress/wp-includes/Requests/Cookie/Jar.php', __DIR__))) { $httpReturnType = 'array{headers: \Requests_Utility_CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error'; @@ -177,6 +177,15 @@ 'WP_Widget::form' => [null, 'instance' => 'T'], 'WP_Widget::update' => [null, 'new_instance' => 'T', 'old_instance' => 'T'], 'WP_Widget::widget' => [null, 'instance' => 'T', 'args' => 'array{name:string,id:string,description:string,class:string,before_widget:string,after_widget:string,before_title:string,after_title:string,before_sidebar:string,after_sidebar:string,show_in_rest:boolean,widget_id:string,widget_name:string}'], + 'get_approved_comments' => ["(\$args is array{count: true} ? int : (\$args is array{fields: 'ids'} ? array : array))"], + 'get_posts' => ["(\$args is array{fields: 'id=>parent'|'ids'} ? array : array)"], + 'get_sites' => ["(\$args is array{count: true} ? int : (\$args is array{fields: 'ids'} ? array : array))"], + 'get_tags' => ["(\$args is array{fields: 'count'} ? numeric-string : (\$args is array{fields: 'names'|'slugs'} ? list : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array : (\$args is array{fields: 'id=>parent'} ? array : (\$args is array{fields: 'ids'|'tt_ids'} ? list : array)))))|\WP_Error"], + 'get_terms' => ["(\$args is array{fields: 'count'} ? numeric-string : (\$args is array{fields: 'names'|'slugs'} ? list : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array : (\$args is array{fields: 'id=>parent'} ? array : (\$args is array{fields: 'ids'|'tt_ids'} ? list : array)))))|\WP_Error"], + 'wp_get_post_categories' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array : (\$args is array{fields: 'id=>parent'} ? array : (\$args is array{fields: 'all'|'all_with_object_id'} ? array : (\$args is array{fields: 'count'} ? numeric-string : list)))))|\WP_Error))"], + 'wp_get_post_tags' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array : (\$args is array{fields: 'id=>parent'} ? array : (\$args is array{fields: 'ids'|'tt_ids'} ? list : (\$args is array{fields: 'count'} ? numeric-string : array)))))|\WP_Error))"], + 'wp_get_post_terms' => ["(\$post_id is 0 ? array{} : (\$taxonomy is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array : (\$args is array{fields: 'id=>parent'} ? array : (\$args is array{fields: 'ids'|'tt_ids'} ? list : (\$args is array{fields: 'count'} ? numeric-string : array)))))|\WP_Error)))"], + 'wp_get_object_terms' => ["(\$object_ids is empty ? array{} : (\$taxonomies is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array : (\$args is array{fields: 'id=>parent'} ? array : (\$args is array{fields: 'ids'|'tt_ids'} ? list : (\$args is array{fields: 'count'} ? numeric-string : array)))))|\WP_Error)))"], 'wp_parse_list' => ['($input_list is array ? array : list)'], 'wp_parse_str' => [null, '@phpstan-param-out' => 'array $result'], 'size_format' => ["(\$bytes is not numeric ? false : (\$bytes is negative-int|'0' ? false : string))"], diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e4906a4..4af178a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -50,6 +50,9 @@ tests/ + + tests/TypeInferenceTest.php + tests/TypeInferenceTest.php diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 1e7f142..bdf00c8 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -12,6 +12,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/_get_list_table.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/current_time.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/echo_parameter.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_approved_comments.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_attachment_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_bookmark.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_categories.php'); @@ -22,9 +23,13 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/get_post.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_post_stati.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_post_types.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_posts.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_page_by_path.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_permalink.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_sites.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_tags.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_term_by.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_terms.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_term.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_taxonomies_for_attachments.php'); @@ -40,6 +45,10 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_error_parameter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_generate_tag_cloud.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_get_archives.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_get_post_categories.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_get_post_tags.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_get_post_terms.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_get_object_terms.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_is_numeric_array.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_list_bookmarks.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_list_categories.php'); diff --git a/tests/data/get_approved_comments.php b/tests/data/get_approved_comments.php new file mode 100644 index 0000000..28ab1e3 --- /dev/null +++ b/tests/data/get_approved_comments.php @@ -0,0 +1,20 @@ +', get_approved_comments(1)); + +assertType('int', get_approved_comments(1, ['count' => true])); + +assertType('int', get_approved_comments(1, ['count' => true,'fields' => 'ids'])); + +assertType('array', get_approved_comments(1, ['count' => false])); + +assertType('array', get_approved_comments(1, ['fields' => 'ids'])); + +assertType('array', get_approved_comments(1, ['count' => false, 'fields' => 'ids'])); diff --git a/tests/data/get_posts.php b/tests/data/get_posts.php new file mode 100644 index 0000000..7cbb151 --- /dev/null +++ b/tests/data/get_posts.php @@ -0,0 +1,67 @@ +', get_posts()); +assertType('array', get_posts(['key' => 'value'])); +assertType('array', get_posts(['fields' => ''])); +assertType('array', get_posts(['fields' => 'ids'])); +assertType('array', get_posts(['fields' => 'id=>parent'])); +assertType('array', get_posts(['fields' => 'Hello'])); + +// Nonconstant array +assertType('array', get_posts((array)$_GET['array'])); + +// Unions +$union = $_GET['foo'] ? ['key' => 'value'] : ['some' => 'thing']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? ['key' => 'value'] : ['fields' => 'ids']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? ['key' => 'value'] : ['fields' => '']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? ['key' => 'value'] : ['fields' => 'id=>parent']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? ['fields' => ''] : ['fields' => 'ids']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? ['fields' => ''] : ['fields' => 'id=>parent']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? ['fields' => 'ids'] : ['fields' => 'id=>parent']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? (array)$_GET['array'] : ['fields' => '']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? (array)$_GET['array'] : ['fields' => 'ids']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? (array)$_GET['array'] : ['fields' => 'id=>parent']; +assertType('array', get_posts($union)); + +$union = $_GET['foo'] ? (string)$_GET['string'] : ''; +assertType('array', get_posts(['fields' => $union])); + +$union = $_GET['foo'] ? (string)$_GET['string'] : 'ids'; +assertType('array', get_posts(['fields' => $union])); + +$union = $_GET['foo'] ? (string)$_GET['string'] : 'id=>parent'; +assertType('array', get_posts(['fields' => $union])); + +$union = $_GET['foo'] ? (string)$_GET['string'] : 'fields'; +assertType('array', get_posts([$union => ''])); + +$union = $_GET['foo'] ? (string)$_GET['string'] : 'fields'; +assertType('array', get_posts([$union => 'ids'])); + +$union = $_GET['foo'] ? (string)$_GET['string'] : 'fields'; +assertType('array', get_posts([$union => 'id=>parent'])); diff --git a/tests/data/get_sites.php b/tests/data/get_sites.php new file mode 100644 index 0000000..a4a809b --- /dev/null +++ b/tests/data/get_sites.php @@ -0,0 +1,34 @@ +', get_sites()); +assertType('array', get_sites([])); + +// Non constant array parameter +/** @var array $value */ +$value = $_GET['foo']; +assertType('array|int', get_sites($value)); + +// Array parameter with explicit fields value and default count value. +assertType('array', get_sites(['fields' => 'ids'])); +assertType('array', get_sites(['fields' => ''])); +assertType('array', get_sites(['fields' => 'nonEmptyString'])); + +// Array parameter with count set to true. +assertType('int', get_sites(['count' => true])); +assertType('int', get_sites(['fields' => '', 'count' => true])); +assertType('int', get_sites(['fields' => 'ids', 'count' => true])); +assertType('int', get_sites(['fields' => 'nonEmptyString', 'count' => true])); + +// Array parameter with count set to false. +assertType('array', get_sites(['count' => false])); +assertType('array', get_sites(['fields' => '', 'count' => false])); +assertType('array', get_sites(['fields' => 'ids', 'count' => false])); +assertType('array', get_sites(['fields' => 'nonEmptyString', 'count' => false])); diff --git a/tests/data/get_tags.php b/tests/data/get_tags.php new file mode 100644 index 0000000..85a74dd --- /dev/null +++ b/tests/data/get_tags.php @@ -0,0 +1,37 @@ + all) +assertType('array|WP_Error', get_tags()); +assertType('array|WP_Error', get_tags([])); + +// Requesting a count +assertType('numeric-string|WP_Error', get_tags(['fields' => 'count'])); +assertType('numeric-string|WP_Error', get_tags(['foo' => 'bar','fields' => 'count'])); + +// Requesting names or slugs +assertType('list|WP_Error', get_tags(['fields' => 'names'])); +assertType('list|WP_Error', get_tags(['fields' => 'slugs'])); +assertType('array|WP_Error', get_tags(['fields' => 'id=>name'])); +assertType('array|WP_Error', get_tags(['fields' => 'id=>slug'])); + +// Requesting IDs +assertType('list|WP_Error', get_tags(['fields' => 'ids'])); +assertType('list|WP_Error', get_tags(['fields' => 'tt_ids'])); + +// Requesting parent IDs +assertType('array|WP_Error', get_tags(['fields' => 'id=>parent'])); + +// Requesting objects +assertType('array|WP_Error', get_tags(['fields' => 'all'])); +assertType('array|WP_Error', get_tags(['fields' => 'all_with_object_id'])); +assertType('array|WP_Error', get_tags(['fields' => 'foo'])); + +// Unknown fields value +assertType('array|numeric-string|WP_Error', get_tags(['fields' => (string)$_GET['fields']])); diff --git a/tests/data/get_terms.php b/tests/data/get_terms.php new file mode 100644 index 0000000..dd83fb2 --- /dev/null +++ b/tests/data/get_terms.php @@ -0,0 +1,37 @@ + all) +assertType('array|WP_Error', get_terms()); +assertType('array|WP_Error', get_terms([])); + +// Requesting a count +assertType('numeric-string|WP_Error', get_terms(['fields' => 'count'])); +assertType('numeric-string|WP_Error', get_terms(['foo' => 'bar','fields' => 'count'])); + +// Requesting names or slugs +assertType('list|WP_Error', get_terms(['fields' => 'names'])); +assertType('list|WP_Error', get_terms(['fields' => 'slugs'])); +assertType('array|WP_Error', get_terms(['fields' => 'id=>name'])); +assertType('array|WP_Error', get_terms(['fields' => 'id=>slug'])); + +// Requesting IDs +assertType('list|WP_Error', get_terms(['fields' => 'ids'])); +assertType('list|WP_Error', get_terms(['fields' => 'tt_ids'])); + +// Requesting parent IDs +assertType('array|WP_Error', get_terms(['fields' => 'id=>parent'])); + +// Requesting objects +assertType('array|WP_Error', get_terms(['fields' => 'all'])); +assertType('array|WP_Error', get_terms(['fields' => 'all_with_object_id'])); +assertType('array|WP_Error', get_terms(['fields' => 'foo'])); + +// Unknown fields value +assertType('array|numeric-string|WP_Error', get_terms(['fields' => (string)$_GET['fields']])); diff --git a/tests/data/wp_get_object_terms.php b/tests/data/wp_get_object_terms.php new file mode 100644 index 0000000..990fb9a --- /dev/null +++ b/tests/data/wp_get_object_terms.php @@ -0,0 +1,45 @@ + all) +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies)); +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, [])); + +// Empty $object_ids or $taxonomies +assertType('array{}', wp_get_object_terms(0, $taxonomies, ['fields' => 'count'])); +assertType('array{}', wp_get_object_terms([], $taxonomies)); +assertType('array{}', wp_get_object_terms($objectIDs, '')); +assertType('array{}', wp_get_object_terms($objectIDs, [])); + +// Requesting names or slugs +assertType('list|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'names'])); +assertType('list|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'slugs'])); +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'id=>name'])); +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'id=>slug'])); + +// Requesting IDs +assertType('list|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'ids'])); +assertType('list|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'tt_ids'])); + +// Requesting parent IDs +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'id=>parent'])); + +// Requesting objects +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'all'])); +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'all_with_object_id'])); +assertType('array|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'foo'])); + +// Requesting a count +assertType('numeric-string|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => 'count'])); + +// Unknown fields value +assertType('array|numeric-string|WP_Error', wp_get_object_terms($objectIDs, $taxonomies, ['fields' => (string)$_GET['fields']])); diff --git a/tests/data/wp_get_post_categories.php b/tests/data/wp_get_post_categories.php new file mode 100644 index 0000000..43827eb --- /dev/null +++ b/tests/data/wp_get_post_categories.php @@ -0,0 +1,41 @@ + ids) +assertType('list|WP_Error', wp_get_post_categories($postID)); +assertType('list|WP_Error', wp_get_post_categories($postID, [])); + +// Empty $post_id +assertType('array{}', wp_get_post_categories(0)); + +// Requesting names or slugs +assertType('list|WP_Error', wp_get_post_categories($postID, ['fields' => 'names'])); +assertType('list|WP_Error', wp_get_post_categories($postID, ['fields' => 'slugs'])); +assertType('array|WP_Error', wp_get_post_categories($postID, ['fields' => 'id=>name'])); +assertType('array|WP_Error', wp_get_post_categories($postID, ['fields' => 'id=>slug'])); + +// Requesting IDs +assertType('list|WP_Error', wp_get_post_categories($postID, ['fields' => 'ids'])); +assertType('list|WP_Error', wp_get_post_categories($postID, ['fields' => 'tt_ids'])); + +// Requesting parent IDs +assertType('array|WP_Error', wp_get_post_categories($postID, ['fields' => 'id=>parent'])); + +// Requesting objects +assertType('array|WP_Error', wp_get_post_categories($postID, ['fields' => 'all'])); +assertType('array|WP_Error', wp_get_post_categories($postID, ['fields' => 'all_with_object_id'])); +assertType('list|WP_Error', wp_get_post_categories($postID, ['fields' => 'foo'])); + +// Requesting a count +assertType('numeric-string|WP_Error', wp_get_post_categories($postID, ['fields' => 'count'])); + +// Unknown fields value +assertType('array|numeric-string|WP_Error', wp_get_post_categories($postID, ['fields' => (string)$_GET['fields']])); diff --git a/tests/data/wp_get_post_tags.php b/tests/data/wp_get_post_tags.php new file mode 100644 index 0000000..d9ab377 --- /dev/null +++ b/tests/data/wp_get_post_tags.php @@ -0,0 +1,41 @@ + all) +assertType('array|WP_Error', wp_get_post_tags($postID)); +assertType('array|WP_Error', wp_get_post_tags($postID, [])); + +// Empty $post_id +assertType('array{}', wp_get_post_tags(0)); + +// Requesting names or slugs +assertType('list|WP_Error', wp_get_post_tags($postID, ['fields' => 'names'])); +assertType('list|WP_Error', wp_get_post_tags($postID, ['fields' => 'slugs'])); +assertType('array|WP_Error', wp_get_post_tags($postID, ['fields' => 'id=>name'])); +assertType('array|WP_Error', wp_get_post_tags($postID, ['fields' => 'id=>slug'])); + +// Requesting IDs +assertType('list|WP_Error', wp_get_post_tags($postID, ['fields' => 'ids'])); +assertType('list|WP_Error', wp_get_post_tags($postID, ['fields' => 'tt_ids'])); + +// Requesting parent IDs +assertType('array|WP_Error', wp_get_post_tags($postID, ['fields' => 'id=>parent'])); + +// Requesting objects +assertType('array|WP_Error', wp_get_post_tags($postID, ['fields' => 'all'])); +assertType('array|WP_Error', wp_get_post_tags($postID, ['fields' => 'all_with_object_id'])); +assertType('array|WP_Error', wp_get_post_tags($postID, ['fields' => 'foo'])); + +// Requesting a count +assertType('numeric-string|WP_Error', wp_get_post_tags($postID, ['fields' => 'count'])); + +// Unknown fields value +assertType('array|numeric-string|WP_Error', wp_get_post_tags($postID, ['fields' => (string)$_GET['fields']])); diff --git a/tests/data/wp_get_post_terms.php b/tests/data/wp_get_post_terms.php new file mode 100644 index 0000000..7617280 --- /dev/null +++ b/tests/data/wp_get_post_terms.php @@ -0,0 +1,44 @@ + all) +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy)); +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, [])); + +// Empty $post_id or $taxonomy +assertType('array{}', wp_get_post_terms(0, $taxonomy)); +assertType('array{}', wp_get_post_terms($postID, '')); +assertType('array{}', wp_get_post_terms($postID, [])); + +// Requesting names or slugs +assertType('list|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'names'])); +assertType('list|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'slugs'])); +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'id=>name'])); +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'id=>slug'])); + +// Requesting IDs +assertType('list|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'ids'])); +assertType('list|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'tt_ids'])); + +// Requesting parent IDs +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'id=>parent'])); + +// Requesting objects +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'all'])); +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'all_with_object_id'])); +assertType('array|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'foo'])); + +// Requesting a count +assertType('numeric-string|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => 'count'])); + +// Unknown fields value +assertType('array|numeric-string|WP_Error', wp_get_post_terms($postID, $taxonomy, ['fields' => (string)$_GET['fields']])); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 0f35167..6843940 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -41475,7 +41475,7 @@ class WP_Http * filename?: string, * limit_response_size?: int, * } $args - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ public function request($url, $args = array()) { @@ -41546,7 +41546,7 @@ public function _get_first_available_transport($args, $url = \null) * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. See WP_Http::response() for details. - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ public function post($url, $args = array()) { @@ -41562,7 +41562,7 @@ public function post($url, $args = array()) * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. See WP_Http::response() for details. - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ public function get($url, $args = array()) { @@ -41578,7 +41578,7 @@ public function get($url, $args = array()) * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. See WP_Http::response() for details. - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ public function head($url, $args = array()) { @@ -102740,6 +102740,7 @@ function sanitize_category_field($field, $value, $cat_id, $context) * @phpstan-param array{ * taxonomy?: string, * } $args + * @phpstan-return ($args is array{fields: 'count'} ? numeric-string : ($args is array{fields: 'names'|'slugs'} ? list : ($args is array{fields: 'id=>name'|'id=>slug'} ? array : ($args is array{fields: 'id=>parent'} ? array : ($args is array{fields: 'ids'|'tt_ids'} ? list : array)))))|\WP_Error */ function get_tags($args = '') { @@ -104032,6 +104033,7 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $ * update_comment_meta_cache?: bool, * update_comment_post_cache?: bool, * } $args + * @phpstan-return ($args is array{count: true} ? int : ($args is array{fields: 'ids'} ? array : array)) */ function get_approved_comments($post_id, $args = array()) { @@ -118457,7 +118459,7 @@ function _wp_http_get_object() * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_safe_remote_request($url, $args = array()) { @@ -118500,7 +118502,7 @@ function wp_safe_remote_request($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_safe_remote_get($url, $args = array()) { @@ -118543,7 +118545,7 @@ function wp_safe_remote_get($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_safe_remote_post($url, $args = array()) { @@ -118586,7 +118588,7 @@ function wp_safe_remote_post($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_safe_remote_head($url, $args = array()) { @@ -118650,7 +118652,7 @@ function wp_safe_remote_head($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_remote_request($url, $args = array()) { @@ -118686,7 +118688,7 @@ function wp_remote_request($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_remote_get($url, $args = array()) { @@ -118722,7 +118724,7 @@ function wp_remote_get($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_remote_post($url, $args = array()) { @@ -118758,7 +118760,7 @@ function wp_remote_post($url, $args = array()) * filename?: string, * limit_response_size?: int, * } $args See WP_Http::request() - * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int,message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error + * @phpstan-return array{headers: \WpOrg\Requests\Utility\CaseInsensitiveDictionary, body: string, response: array{code: int, message: string}, cookies: array, filename: string|null, http_response: \WP_HTTP_Requests_Response}|\WP_Error */ function wp_remote_head($url, $args = array()) { @@ -128249,6 +128251,7 @@ function update_sitemeta_cache($site_ids) * meta_type_key?: string, * meta_query?: array, * } $args See WP_Site_Query::__construct() + * @phpstan-return ($args is array{count: true} ? int : ($args is array{fields: 'ids'} ? array : array)) */ function get_sites($args = array()) { @@ -133662,6 +133665,7 @@ function is_post_publicly_viewable($post = \null) * w?: int, * year?: int, * } $args + * @phpstan-return ($args is array{fields: 'id=>parent'|'ids'} ? array : array) */ function get_posts($args = \null) { @@ -134176,6 +134180,7 @@ function wp_untrash_post_comments($post = \null) * meta_type_key?: string, * meta_query?: array, * } $args See WP_Term_Query::__construct() + * @phpstan-return ($post_id is 0 ? array{} : (($args is array{fields: 'names'|'slugs'} ? list : ($args is array{fields: 'id=>name'|'id=>slug'} ? array : ($args is array{fields: 'id=>parent'} ? array : ($args is array{fields: 'all'|'all_with_object_id'} ? array : ($args is array{fields: 'count'} ? numeric-string : list)))))|\WP_Error)) */ function wp_get_post_categories($post_id = 0, $args = array()) { @@ -134231,6 +134236,7 @@ function wp_get_post_categories($post_id = 0, $args = array()) * meta_type_key?: string, * meta_query?: array, * } $args See WP_Term_Query::__construct() + * @phpstan-return ($post_id is 0 ? array{} : (($args is array{fields: 'names'|'slugs'} ? list : ($args is array{fields: 'id=>name'|'id=>slug'} ? array : ($args is array{fields: 'id=>parent'} ? array : ($args is array{fields: 'ids'|'tt_ids'} ? list : ($args is array{fields: 'count'} ? numeric-string : array)))))|\WP_Error)) */ function wp_get_post_tags($post_id = 0, $args = array()) { @@ -134288,6 +134294,7 @@ function wp_get_post_tags($post_id = 0, $args = array()) * meta_type_key?: string, * meta_query?: array, * } $args + * @phpstan-return ($post_id is 0 ? array{} : ($taxonomy is empty ? array{} : (($args is array{fields: 'names'|'slugs'} ? list : ($args is array{fields: 'id=>name'|'id=>slug'} ? array : ($args is array{fields: 'id=>parent'} ? array : ($args is array{fields: 'ids'|'tt_ids'} ? list : ($args is array{fields: 'count'} ? numeric-string : array)))))|\WP_Error))) */ function wp_get_post_terms($post_id = 0, $taxonomy = 'post_tag', $args = array()) { @@ -140389,6 +140396,7 @@ function get_term_to_edit($id, $taxonomy) * meta_type_key?: string, * meta_query?: array, * } $args See WP_Term_Query::__construct() + * @phpstan-return ($args is array{fields: 'count'} ? numeric-string : ($args is array{fields: 'names'|'slugs'} ? list : ($args is array{fields: 'id=>name'|'id=>slug'} ? array : ($args is array{fields: 'id=>parent'} ? array : ($args is array{fields: 'ids'|'tt_ids'} ? list : array)))))|\WP_Error */ function get_terms($args = array(), $deprecated = '') { @@ -140812,6 +140820,7 @@ function wp_delete_category($cat_id) * meta_type_key?: string, * meta_query?: array, * } $args See WP_Term_Query::__construct() + * @phpstan-return ($object_ids is empty ? array{} : ($taxonomies is empty ? array{} : (($args is array{fields: 'names'|'slugs'} ? list : ($args is array{fields: 'id=>name'|'id=>slug'} ? array : ($args is array{fields: 'id=>parent'} ? array : ($args is array{fields: 'ids'|'tt_ids'} ? list : ($args is array{fields: 'count'} ? numeric-string : array)))))|\WP_Error))) */ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {