From 03c7b04f8e4227f5127042303d82e68f96ba4327 Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:29:32 +0200 Subject: [PATCH 1/4] Use unsealed shapes in conditional return types #248 --- functionMap.php | 46 ++++++++++++++++++++++----------------------- wordpress-stubs.php | 46 ++++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/functionMap.php b/functionMap.php index 4aa2bd8..ffaa87e 100644 --- a/functionMap.php +++ b/functionMap.php @@ -43,7 +43,7 @@ 'bool_from_yn' => ["(\$yn is 'y' ? true : false)"], 'have_posts' => [null, '@phpstan-impure' => ''], 'is_new_day' => ['0|1'], - 'paginate_links' => ["(\$args is array{total: int} ? void : (\$args is array{type: 'array'} ? list : string))"], + 'paginate_links' => ["(\$args is array{total: int, ...} ? void : (\$args is array{type: 'array', ...} ? list : string))"], 'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'], 'sanitize_post' => ['T', '@phpstan-template' => 'T of array|object', 'post' => 'T'], @@ -53,22 +53,22 @@ 'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"], - 'wp_die' => ['($args is array{exit: false} ? void : never)'], - 'wp_dropdown_languages' => ["(\$args is array{id: null|''} ? void : (\$args is array{name: null|''} ? void : string))"], + 'wp_die' => ['($args is array{exit: false, ...} ? void : never)'], + 'wp_dropdown_languages' => ["(\$args is array{id: null|'', ...} ? void : (\$args is array{name: null|'', ...} ? void : string))"], 'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType], - 'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'} ? array : string)"], + 'wp_generate_tag_cloud' => ["(\$args is array{format: 'array', ...} ? array : string)"], 'wp_get_schedule' => [null, 'args' => $cronArgsType], 'wp_get_scheduled_event' => [null, 'args' => $cronArgsType], - 'wp_get_archives' => ['($args is array{echo: false|0} ? string|void : void)'], + 'wp_get_archives' => ['($args is array{echo: false|0, ...} ? string|void : void)'], 'WP_Http::get' => [$httpReturnType], 'WP_Http::head' => [$httpReturnType], 'WP_Http::post' => [$httpReturnType], 'WP_Http::request' => [$httpReturnType], 'wp_is_numeric_array' => ['(T is array ? (key-of is int ? true : false) : false)', '@template' => 'T of mixed', 'data' => 'T', '@phpstan-assert-if-true' => '(T is list ? T : array>) $data'], - 'wp_list_bookmarks' => ['($args is array{echo: false|0} ? string : void)'], - 'wp_list_categories' => ['($args is array{echo: false|0} ? string|false : false|void)'], - 'wp_list_pages' => ['($args is array{echo: false} ? string : void)'], - 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'], + 'wp_list_bookmarks' => ['($args is array{echo: false|0, ...} ? string : void)'], + 'wp_list_categories' => ['($args is array{echo: false|0, ...} ? string|false : false|void)'], + 'wp_list_pages' => ['($args is array{echo: false, ...} ? string : void)'], + 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int, ...}'], 'wp_next_scheduled' => [null, 'args' => $cronArgsType], 'WP_Query::have_posts' => [null, '@phpstan-impure' => ''], 'wp_remote_get' => [$httpReturnType], @@ -83,7 +83,7 @@ 'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType], 'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType], 'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], - 'wp_tag_cloud' => ["(\$args is array{format: 'array'} ? array|void : (\$args is array{echo: false|0} ? string|void : void))"], + 'wp_tag_cloud' => ["(\$args is array{format: 'array', ...} ? array|void : (\$args is array{echo: false|0, ...} ? string|void : void))"], 'wp_trigger_error' => [null, 'function_name' => 'callable-string', 'error_level' => '\E_USER_ERROR|\E_USER_WARNING|\E_USER_NOTICE|\E_USER_DEPRECATED'], 'wp_unique_id' => ['($prefix is empty ? numeric-string : ($prefix is numeric ? numeric-string : string))'], 'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType], @@ -144,9 +144,9 @@ 'get_permalink' => ['($post is \WP_Post ? string : string|false)'], 'get_the_permalink' => ['($post is \WP_Post ? string : string|false)'], 'get_post_permalink' => ['($post is \WP_Post ? string : string|false)'], - 'term_exists' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null)))"], - 'is_term' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null)))"], - 'tag_exists' => ["(\$tag_name is 0 ? 0 : (\$tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string}|null))"], + 'term_exists' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null)))"], + 'is_term' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null)))"], + 'tag_exists' => ["(\$tag_name is 0 ? 0 : (\$tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string, ...}|null))"], 'wp_insert_link' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'], 'wp_insert_category' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'], 'wp_insert_post' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'], @@ -182,22 +182,22 @@ 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? list : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => '0|positive-int'], 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? list> : (\$output is 'ARRAY_N' ? list> : (\$output is 'OBJECT_K' ? array : list<\stdClass>)))", 'output' => "'OBJECT'|'OBJECT_K'|'ARRAY_A'|'ARRAY_N'"], 'get_bookmark' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], - 'get_categories' => ["(\$args is array{fields: 'count'} ? list : (\$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)))))"], + 'get_categories' => ["(\$args is array{fields: 'count', ...} ? list : (\$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)))))"], 'get_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], 'get_category_by_path' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], 'WP_Widget' => [null, '@phpstan-template' => 'T of array'], '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)))"], + '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_json_encode' => ['non-empty-string|false', 'depth' => 'positive-int'], 'wp_parse_list' => ['($input_list is array ? array : list)'], 'wp_parse_str' => [null, '@phpstan-param-out' => 'array $result'], diff --git a/wordpress-stubs.php b/wordpress-stubs.php index b9282fe..ee19f96 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -3663,7 +3663,7 @@ public function prepare_items() * @since 3.1.0 * * @param array|string $args Array or string of arguments with information about the pagination. - * @phpstan-param array{total_items?: int, total_pages?: int, per_page?: int} $args + * @phpstan-param array{total_items?: int, total_pages?: int, per_page?: int, ...} $args * @phpstan-return void */ protected function set_pagination_args($args) @@ -86526,7 +86526,7 @@ function wp_update_category($catarr) * @return mixed Returns null if the term does not exist. * Returns an array of the term ID and the term taxonomy ID if the pairing exists. * Returns 0 if term ID 0 is passed to the function. - * @phpstan-return ($tag_name is 0 ? 0 : ($tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string}|null)) + * @phpstan-return ($tag_name is 0 ? 0 : ($tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string, ...}|null)) */ function tag_exists($tag_name) { @@ -95851,7 +95851,7 @@ function _walk_bookmarks($bookmarks, $args = '') * category_orderby?: string, * category_order?: string, * } $args - * @phpstan-return ($args is array{echo: false|0} ? string : void) + * @phpstan-return ($args is array{echo: false|0, ...} ? string : void) */ function wp_list_bookmarks($args = '') { @@ -97019,7 +97019,7 @@ function wp_dropdown_categories($args = '') * walker?: Walker, * taxonomy?: string, * } $args - * @phpstan-return ($args is array{echo: false|0} ? string|false : false|void) + * @phpstan-return ($args is array{echo: false|0, ...} ? string|false : false|void) */ function wp_list_categories($args = '') { @@ -97068,7 +97068,7 @@ function wp_list_categories($args = '') * topic_count_scale_callback?: callable, * show_count?: bool|int, * } $args - * @phpstan-return ($args is array{format: 'array'} ? array|void : ($args is array{echo: false|0} ? string|void : void)) + * @phpstan-return ($args is array{format: 'array', ...} ? array|void : ($args is array{echo: false|0, ...} ? string|void : void)) */ function wp_tag_cloud($args = '') { @@ -97144,7 +97144,7 @@ function default_topic_count_scale($count) * topic_count_scale_callback?: callable, * show_count?: bool|int, * } $args - * @phpstan-return ($args is array{format: 'array'} ? array : string) + * @phpstan-return ($args is array{format: 'array', ...} ? array : string) */ function wp_generate_tag_cloud($tags, $args = '') { @@ -97446,7 +97446,7 @@ function has_term($term = '', $taxonomy = '', $post = \null) * @phpstan-param array{ * taxonomy?: string, * } $args - * @phpstan-return ($args is array{fields: 'count'} ? list : ($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))))) + * @phpstan-return ($args is array{fields: 'count', ...} ? list : ($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))))) */ function get_categories($args = '') { @@ -97596,7 +97596,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 + * @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 = '') { @@ -98874,7 +98874,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)) + * @phpstan-return ($args is array{count: true, ...} ? int : ($args is array{fields: 'ids', ...} ? array : array)) */ function get_approved_comments($post_id, $args = array()) { @@ -102212,7 +102212,7 @@ function is_taxonomy($taxonomy) * @param string $taxonomy The taxonomy name to use * @param int $parent ID of parent term under which to confine the exists search. * @return mixed Get the term ID or term object, if exists. - * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null))) + * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null))) */ function is_term($term, $taxonomy = '', $parent = 0) { @@ -108697,7 +108697,7 @@ function wp_nonce_ays($action) * code?: string, * exit?: bool, * } $args - * @phpstan-return ($args is array{exit: false} ? void : never) + * @phpstan-return ($args is array{exit: false, ...} ? void : never) */ function wp_die($message = '', $title = '', $args = array()) { @@ -111994,7 +111994,7 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after = * day?: string, * w?: string, * } $args - * @phpstan-return ($args is array{echo: false|0} ? string|void : void) + * @phpstan-return ($args is array{echo: false|0, ...} ? string|void : void) */ function wp_get_archives($args = '') { @@ -112735,7 +112735,7 @@ function language_attributes($doctype = 'html') * before_page_number?: string, * after_page_number?: string, * } $args - * @phpstan-return ($args is array{total: int} ? void : ($args is array{type: 'array'} ? list : string)) + * @phpstan-return ($args is array{total: int, ...} ? void : ($args is array{type: 'array', ...} ? list : string)) */ function paginate_links($args = '') { @@ -115543,7 +115543,7 @@ function wp_get_l10n_php_file_data($php_file) * show_option_en_us?: bool, * explicit_option_en_us?: bool, * } $args - * @phpstan-return ($args is array{id: null|''} ? void : ($args is array{name: null|''} ? void : string)) + * @phpstan-return ($args is array{id: null|'', ...} ? void : ($args is array{name: null|'', ...} ? void : string)) */ function wp_dropdown_languages($args = array()) { @@ -122899,7 +122899,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)) + * @phpstan-return ($args is array{count: true, ...} ? int : ($args is array{fields: 'ids', ...} ? array : array)) */ function get_sites($args = array()) { @@ -126722,7 +126722,7 @@ function wp_dropdown_pages($args = '') * post_type?: string, * post_status?: string|array, * } $args - * @phpstan-return ($args is array{echo: false} ? string : void) + * @phpstan-return ($args is array{echo: false, ...} ? string : void) */ function wp_list_pages($args = '') { @@ -128247,7 +128247,7 @@ function is_post_publicly_viewable($post = \null) * w?: int, * year?: int, * } $args - * @phpstan-return ($args is array{fields: 'id=>parent'|'ids'} ? array : array) + * @phpstan-return ($args is array{fields: 'id=>parent'|'ids', ...} ? array : array) */ function get_posts($args = \null) { @@ -128759,7 +128759,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)) + * @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()) { @@ -128815,7 +128815,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)) + * @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()) { @@ -128873,7 +128873,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))) + * @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()) { @@ -134890,7 +134890,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 + * @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 = '') { @@ -135067,7 +135067,7 @@ function unregister_term_meta($taxonomy, $meta_key) * Returns the term ID if no taxonomy is specified and the term ID exists. * Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists. * Returns 0 if term ID 0 is passed to the function. - * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null))) + * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null))) */ function term_exists($term, $taxonomy = '', $parent_term = \null) { @@ -135314,7 +135314,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))) + * @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()) { From de3ad403fc7b07414a9272fdaae726b9c572247b Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:59:24 +0200 Subject: [PATCH 2/4] Remove mistakenly added unsealed shapes --- functionMap.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functionMap.php b/functionMap.php index ffaa87e..d809996 100644 --- a/functionMap.php +++ b/functionMap.php @@ -68,7 +68,7 @@ 'wp_list_bookmarks' => ['($args is array{echo: false|0, ...} ? string : void)'], 'wp_list_categories' => ['($args is array{echo: false|0, ...} ? string|false : false|void)'], 'wp_list_pages' => ['($args is array{echo: false, ...} ? string : void)'], - 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int, ...}'], + 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'], 'wp_next_scheduled' => [null, 'args' => $cronArgsType], 'WP_Query::have_posts' => [null, '@phpstan-impure' => ''], 'wp_remote_get' => [$httpReturnType], @@ -144,9 +144,9 @@ 'get_permalink' => ['($post is \WP_Post ? string : string|false)'], 'get_the_permalink' => ['($post is \WP_Post ? string : string|false)'], 'get_post_permalink' => ['($post is \WP_Post ? string : string|false)'], - 'term_exists' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null)))"], - 'is_term' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null)))"], - 'tag_exists' => ["(\$tag_name is 0 ? 0 : (\$tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string, ...}|null))"], + 'term_exists' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null)))"], + 'is_term' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null)))"], + 'tag_exists' => ["(\$tag_name is 0 ? 0 : (\$tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string}|null))"], 'wp_insert_link' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'], 'wp_insert_category' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'], 'wp_insert_post' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'], From 274fe52a80f2227e8f7a10ee994602fb61c830c7 Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:01:59 +0200 Subject: [PATCH 3/4] Replace ... notation with pseudo intersections --- functionMap.php | 38 ++++++++++++++++++------------------- wordpress-stubs.php | 46 ++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/functionMap.php b/functionMap.php index d809996..766d5ae 100644 --- a/functionMap.php +++ b/functionMap.php @@ -43,7 +43,7 @@ 'bool_from_yn' => ["(\$yn is 'y' ? true : false)"], 'have_posts' => [null, '@phpstan-impure' => ''], 'is_new_day' => ['0|1'], - 'paginate_links' => ["(\$args is array{total: int, ...} ? void : (\$args is array{type: 'array', ...} ? list : string))"], + 'paginate_links' => ["(\$args is array{total: int}&array ? void : (\$args is array{type: 'array', ...} ? list : string))"], 'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'], 'sanitize_post' => ['T', '@phpstan-template' => 'T of array|object', 'post' => 'T'], @@ -53,21 +53,21 @@ 'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"], - 'wp_die' => ['($args is array{exit: false, ...} ? void : never)'], - 'wp_dropdown_languages' => ["(\$args is array{id: null|'', ...} ? void : (\$args is array{name: null|'', ...} ? void : string))"], + 'wp_die' => ['($args is array{exit: false}&array ? void : never)'], + 'wp_dropdown_languages' => ["(\$args is array{id: null|''}&array ? void : (\$args is array{name: null|''}&array ? void : string))"], 'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType], - 'wp_generate_tag_cloud' => ["(\$args is array{format: 'array', ...} ? array : string)"], + 'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'}&array ? array : string)"], 'wp_get_schedule' => [null, 'args' => $cronArgsType], 'wp_get_scheduled_event' => [null, 'args' => $cronArgsType], - 'wp_get_archives' => ['($args is array{echo: false|0, ...} ? string|void : void)'], + 'wp_get_archives' => ['($args is array{echo: false|0}&array ? string|void : void)'], 'WP_Http::get' => [$httpReturnType], 'WP_Http::head' => [$httpReturnType], 'WP_Http::post' => [$httpReturnType], 'WP_Http::request' => [$httpReturnType], 'wp_is_numeric_array' => ['(T is array ? (key-of is int ? true : false) : false)', '@template' => 'T of mixed', 'data' => 'T', '@phpstan-assert-if-true' => '(T is list ? T : array>) $data'], - 'wp_list_bookmarks' => ['($args is array{echo: false|0, ...} ? string : void)'], - 'wp_list_categories' => ['($args is array{echo: false|0, ...} ? string|false : false|void)'], - 'wp_list_pages' => ['($args is array{echo: false, ...} ? string : void)'], + 'wp_list_bookmarks' => ['($args is array{echo: false|0}&array ? string : void)'], + 'wp_list_categories' => ['($args is array{echo: false|0}&array ? string|false : false|void)'], + 'wp_list_pages' => ['($args is array{echo: false}&array ? string : void)'], 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'], 'wp_next_scheduled' => [null, 'args' => $cronArgsType], 'WP_Query::have_posts' => [null, '@phpstan-impure' => ''], @@ -83,7 +83,7 @@ 'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType], 'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType], 'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], - 'wp_tag_cloud' => ["(\$args is array{format: 'array', ...} ? array|void : (\$args is array{echo: false|0, ...} ? string|void : void))"], + 'wp_tag_cloud' => ["(\$args is array{format: 'array'}&array ? array|void : (\$args is array{echo: false|0}&array ? string|void : void))"], 'wp_trigger_error' => [null, 'function_name' => 'callable-string', 'error_level' => '\E_USER_ERROR|\E_USER_WARNING|\E_USER_NOTICE|\E_USER_DEPRECATED'], 'wp_unique_id' => ['($prefix is empty ? numeric-string : ($prefix is numeric ? numeric-string : string))'], 'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType], @@ -182,22 +182,22 @@ 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? list : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => '0|positive-int'], 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? list> : (\$output is 'ARRAY_N' ? list> : (\$output is 'OBJECT_K' ? array : list<\stdClass>)))", 'output' => "'OBJECT'|'OBJECT_K'|'ARRAY_A'|'ARRAY_N'"], 'get_bookmark' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], - 'get_categories' => ["(\$args is array{fields: 'count', ...} ? list : (\$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)))))"], + 'get_categories' => ["(\$args is array{fields: 'count'}&array ? list : (\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list : array)))))"], 'get_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], 'get_category_by_path' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], 'WP_Widget' => [null, '@phpstan-template' => 'T of array'], '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)))"], + 'get_approved_comments' => ["(\$args is array{count: true}&array ? int : (\$args is array{fields: 'ids'}&array ? array : array))"], + 'get_posts' => ["(\$args is array{fields: 'id=>parent'|'ids'}&array ? array : array)"], + 'get_sites' => ["(\$args is array{count: true}&array ? int : (\$args is array{fields: 'ids'}&array ? array : array))"], + 'get_tags' => ["(\$args is array{fields: 'count'}&array ? numeric-string : (\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list : array)))))|\WP_Error"], + 'get_terms' => ["(\$args is array{fields: 'count'}&array ? numeric-string : (\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list : array)))))|\WP_Error"], + 'wp_get_post_categories' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'all'|'all_with_object_id'}&array ? array : (\$args is array{fields: 'count'}&array ? numeric-string : list)))))|\WP_Error))"], + 'wp_get_post_tags' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list : (\$args is array{fields: 'count'}&array ? numeric-string : array)))))|\WP_Error))"], + 'wp_get_post_terms' => ["(\$post_id is 0 ? array{} : (\$taxonomy is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list : (\$args is array{fields: 'count'}&array ? numeric-string : array)))))|\WP_Error)))"], + 'wp_get_object_terms' => ["(\$object_ids is empty ? array{} : (\$taxonomies is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array : (\$args is array{fields: 'id=>parent'}&array ? array : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list : (\$args is array{fields: 'count'}&array ? numeric-string : array)))))|\WP_Error)))"], 'wp_json_encode' => ['non-empty-string|false', 'depth' => 'positive-int'], 'wp_parse_list' => ['($input_list is array ? array : list)'], 'wp_parse_str' => [null, '@phpstan-param-out' => 'array $result'], diff --git a/wordpress-stubs.php b/wordpress-stubs.php index ee19f96..9ca6cbe 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -3663,7 +3663,7 @@ public function prepare_items() * @since 3.1.0 * * @param array|string $args Array or string of arguments with information about the pagination. - * @phpstan-param array{total_items?: int, total_pages?: int, per_page?: int, ...} $args + * @phpstan-param array{total_items?: int, total_pages?: int, per_page?: int} $args * @phpstan-return void */ protected function set_pagination_args($args) @@ -86526,7 +86526,7 @@ function wp_update_category($catarr) * @return mixed Returns null if the term does not exist. * Returns an array of the term ID and the term taxonomy ID if the pairing exists. * Returns 0 if term ID 0 is passed to the function. - * @phpstan-return ($tag_name is 0 ? 0 : ($tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string, ...}|null)) + * @phpstan-return ($tag_name is 0 ? 0 : ($tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string}|null)) */ function tag_exists($tag_name) { @@ -95851,7 +95851,7 @@ function _walk_bookmarks($bookmarks, $args = '') * category_orderby?: string, * category_order?: string, * } $args - * @phpstan-return ($args is array{echo: false|0, ...} ? string : void) + * @phpstan-return ($args is array{echo: false|0}&array ? string : void) */ function wp_list_bookmarks($args = '') { @@ -97019,7 +97019,7 @@ function wp_dropdown_categories($args = '') * walker?: Walker, * taxonomy?: string, * } $args - * @phpstan-return ($args is array{echo: false|0, ...} ? string|false : false|void) + * @phpstan-return ($args is array{echo: false|0}&array ? string|false : false|void) */ function wp_list_categories($args = '') { @@ -97068,7 +97068,7 @@ function wp_list_categories($args = '') * topic_count_scale_callback?: callable, * show_count?: bool|int, * } $args - * @phpstan-return ($args is array{format: 'array', ...} ? array|void : ($args is array{echo: false|0, ...} ? string|void : void)) + * @phpstan-return ($args is array{format: 'array'}&array ? array|void : ($args is array{echo: false|0}&array ? string|void : void)) */ function wp_tag_cloud($args = '') { @@ -97144,7 +97144,7 @@ function default_topic_count_scale($count) * topic_count_scale_callback?: callable, * show_count?: bool|int, * } $args - * @phpstan-return ($args is array{format: 'array', ...} ? array : string) + * @phpstan-return ($args is array{format: 'array'}&array ? array : string) */ function wp_generate_tag_cloud($tags, $args = '') { @@ -97446,7 +97446,7 @@ function has_term($term = '', $taxonomy = '', $post = \null) * @phpstan-param array{ * taxonomy?: string, * } $args - * @phpstan-return ($args is array{fields: 'count', ...} ? list : ($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))))) + * @phpstan-return ($args is array{fields: 'count'}&array ? list : ($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'ids'|'tt_ids'}&array ? list : array))))) */ function get_categories($args = '') { @@ -97596,7 +97596,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 + * @phpstan-return ($args is array{fields: 'count'}&array ? numeric-string : ($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'ids'|'tt_ids'}&array ? list : array)))))|\WP_Error */ function get_tags($args = '') { @@ -98874,7 +98874,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)) + * @phpstan-return ($args is array{count: true}&array ? int : ($args is array{fields: 'ids'}&array ? array : array)) */ function get_approved_comments($post_id, $args = array()) { @@ -102212,7 +102212,7 @@ function is_taxonomy($taxonomy) * @param string $taxonomy The taxonomy name to use * @param int $parent ID of parent term under which to confine the exists search. * @return mixed Get the term ID or term object, if exists. - * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null))) + * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null))) */ function is_term($term, $taxonomy = '', $parent = 0) { @@ -108697,7 +108697,7 @@ function wp_nonce_ays($action) * code?: string, * exit?: bool, * } $args - * @phpstan-return ($args is array{exit: false, ...} ? void : never) + * @phpstan-return ($args is array{exit: false}&array ? void : never) */ function wp_die($message = '', $title = '', $args = array()) { @@ -111994,7 +111994,7 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after = * day?: string, * w?: string, * } $args - * @phpstan-return ($args is array{echo: false|0, ...} ? string|void : void) + * @phpstan-return ($args is array{echo: false|0}&array ? string|void : void) */ function wp_get_archives($args = '') { @@ -112735,7 +112735,7 @@ function language_attributes($doctype = 'html') * before_page_number?: string, * after_page_number?: string, * } $args - * @phpstan-return ($args is array{total: int, ...} ? void : ($args is array{type: 'array', ...} ? list : string)) + * @phpstan-return ($args is array{total: int}&array ? void : ($args is array{type: 'array', ...} ? list : string)) */ function paginate_links($args = '') { @@ -115543,7 +115543,7 @@ function wp_get_l10n_php_file_data($php_file) * show_option_en_us?: bool, * explicit_option_en_us?: bool, * } $args - * @phpstan-return ($args is array{id: null|'', ...} ? void : ($args is array{name: null|'', ...} ? void : string)) + * @phpstan-return ($args is array{id: null|''}&array ? void : ($args is array{name: null|''}&array ? void : string)) */ function wp_dropdown_languages($args = array()) { @@ -122899,7 +122899,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)) + * @phpstan-return ($args is array{count: true}&array ? int : ($args is array{fields: 'ids'}&array ? array : array)) */ function get_sites($args = array()) { @@ -126722,7 +126722,7 @@ function wp_dropdown_pages($args = '') * post_type?: string, * post_status?: string|array, * } $args - * @phpstan-return ($args is array{echo: false, ...} ? string : void) + * @phpstan-return ($args is array{echo: false}&array ? string : void) */ function wp_list_pages($args = '') { @@ -128247,7 +128247,7 @@ function is_post_publicly_viewable($post = \null) * w?: int, * year?: int, * } $args - * @phpstan-return ($args is array{fields: 'id=>parent'|'ids', ...} ? array : array) + * @phpstan-return ($args is array{fields: 'id=>parent'|'ids'}&array ? array : array) */ function get_posts($args = \null) { @@ -128759,7 +128759,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)) + * @phpstan-return ($post_id is 0 ? array{} : (($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'all'|'all_with_object_id'}&array ? array : ($args is array{fields: 'count'}&array ? numeric-string : list)))))|\WP_Error)) */ function wp_get_post_categories($post_id = 0, $args = array()) { @@ -128815,7 +128815,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)) + * @phpstan-return ($post_id is 0 ? array{} : (($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'ids'|'tt_ids'}&array ? list : ($args is array{fields: 'count'}&array ? numeric-string : array)))))|\WP_Error)) */ function wp_get_post_tags($post_id = 0, $args = array()) { @@ -128873,7 +128873,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))) + * @phpstan-return ($post_id is 0 ? array{} : ($taxonomy is empty ? array{} : (($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'ids'|'tt_ids'}&array ? list : ($args is array{fields: 'count'}&array ? numeric-string : array)))))|\WP_Error))) */ function wp_get_post_terms($post_id = 0, $taxonomy = 'post_tag', $args = array()) { @@ -134890,7 +134890,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 + * @phpstan-return ($args is array{fields: 'count'}&array ? numeric-string : ($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'ids'|'tt_ids'}&array ? list : array)))))|\WP_Error */ function get_terms($args = array(), $deprecated = '') { @@ -135067,7 +135067,7 @@ function unregister_term_meta($taxonomy, $meta_key) * Returns the term ID if no taxonomy is specified and the term ID exists. * Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists. * Returns 0 if term ID 0 is passed to the function. - * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string, ...}|null))) + * @phpstan-return ($term is 0 ? 0 : ($term is '' ? null : ($taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null))) */ function term_exists($term, $taxonomy = '', $parent_term = \null) { @@ -135314,7 +135314,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))) + * @phpstan-return ($object_ids is empty ? array{} : ($taxonomies is empty ? array{} : (($args is array{fields: 'names'|'slugs'}&array ? list : ($args is array{fields: 'id=>name'|'id=>slug'}&array ? array : ($args is array{fields: 'id=>parent'}&array ? array : ($args is array{fields: 'ids'|'tt_ids'}&array ? list : ($args is array{fields: 'count'}&array ? numeric-string : array)))))|\WP_Error))) */ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) { From a32e45bb1013f975b7306a9457a744ffdb417f63 Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:07:38 +0200 Subject: [PATCH 4/4] Replace ... notation with pseudo intersections --- functionMap.php | 2 +- wordpress-stubs.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functionMap.php b/functionMap.php index 766d5ae..3162de3 100644 --- a/functionMap.php +++ b/functionMap.php @@ -43,7 +43,7 @@ 'bool_from_yn' => ["(\$yn is 'y' ? true : false)"], 'have_posts' => [null, '@phpstan-impure' => ''], 'is_new_day' => ['0|1'], - 'paginate_links' => ["(\$args is array{total: int}&array ? void : (\$args is array{type: 'array', ...} ? list : string))"], + 'paginate_links' => ["(\$args is array{total: int}&array ? void : (\$args is array{type: 'array'}&array ? list : string))"], 'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'], 'sanitize_post' => ['T', '@phpstan-template' => 'T of array|object', 'post' => 'T'], diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 9ca6cbe..1dc60ea 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -112735,7 +112735,7 @@ function language_attributes($doctype = 'html') * before_page_number?: string, * after_page_number?: string, * } $args - * @phpstan-return ($args is array{total: int}&array ? void : ($args is array{type: 'array', ...} ? list : string)) + * @phpstan-return ($args is array{total: int}&array ? void : ($args is array{type: 'array'}&array ? list : string)) */ function paginate_links($args = '') {