Skip to content

Commit 113b3f7

Browse files
authored
Use unsealed shapes in conditional return types (#251)
* Use unsealed shapes in conditional return types #248 * Remove mistakenly added unsealed shapes * Replace ... notation with pseudo intersections * Replace ... notation with pseudo intersections
1 parent 1c0dfa8 commit 113b3f7

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

functionMap.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'bool_from_yn' => ["(\$yn is 'y' ? true : false)"],
4444
'have_posts' => [null, '@phpstan-impure' => ''],
4545
'is_new_day' => ['0|1'],
46-
'paginate_links' => ["(\$args is array{total: int<min, 1>} ? void : (\$args is array{type: 'array'} ? list<string> : string))"],
46+
'paginate_links' => ["(\$args is array{total: int<min, 1>}&array ? void : (\$args is array{type: 'array'}&array ? list<string> : string))"],
4747
'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
4848
'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'],
4949
'sanitize_post' => ['T', '@phpstan-template' => 'T of array|object', 'post' => 'T'],
@@ -53,21 +53,21 @@
5353
'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
5454
'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
5555
'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"],
56-
'wp_die' => ['($args is array{exit: false} ? void : never)'],
57-
'wp_dropdown_languages' => ["(\$args is array{id: null|''} ? void : (\$args is array{name: null|''} ? void : string))"],
56+
'wp_die' => ['($args is array{exit: false}&array ? void : never)'],
57+
'wp_dropdown_languages' => ["(\$args is array{id: null|''}&array ? void : (\$args is array{name: null|''}&array ? void : string))"],
5858
'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType],
59-
'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'} ? array<int, string> : string)"],
59+
'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'}&array ? array<int, string> : string)"],
6060
'wp_get_schedule' => [null, 'args' => $cronArgsType],
6161
'wp_get_scheduled_event' => [null, 'args' => $cronArgsType],
62-
'wp_get_archives' => ['($args is array{echo: false|0} ? string|void : void)'],
62+
'wp_get_archives' => ['($args is array{echo: false|0}&array ? string|void : void)'],
6363
'WP_Http::get' => [$httpReturnType],
6464
'WP_Http::head' => [$httpReturnType],
6565
'WP_Http::post' => [$httpReturnType],
6666
'WP_Http::request' => [$httpReturnType],
6767
'wp_is_numeric_array' => ['(T is array ? (key-of<T> is int ? true : false) : false)', '@template' => 'T of mixed', 'data' => 'T', '@phpstan-assert-if-true' => '(T is list ? T : array<int, value-of<T>>) $data'],
68-
'wp_list_bookmarks' => ['($args is array{echo: false|0} ? string : void)'],
69-
'wp_list_categories' => ['($args is array{echo: false|0} ? string|false : false|void)'],
70-
'wp_list_pages' => ['($args is array{echo: false} ? string : void)'],
68+
'wp_list_bookmarks' => ['($args is array{echo: false|0}&array ? string : void)'],
69+
'wp_list_categories' => ['($args is array{echo: false|0}&array ? string|false : false|void)'],
70+
'wp_list_pages' => ['($args is array{echo: false}&array ? string : void)'],
7171
'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'],
7272
'wp_next_scheduled' => [null, 'args' => $cronArgsType],
7373
'WP_Query::have_posts' => [null, '@phpstan-impure' => ''],
@@ -83,7 +83,7 @@
8383
'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
8484
'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
8585
'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'],
86-
'wp_tag_cloud' => ["(\$args is array{format: 'array'} ? array<int, string>|void : (\$args is array{echo: false|0} ? string|void : void))"],
86+
'wp_tag_cloud' => ["(\$args is array{format: 'array'}&array ? array<int, string>|void : (\$args is array{echo: false|0}&array ? string|void : void))"],
8787
'wp_trigger_error' => [null, 'function_name' => 'callable-string', 'error_level' => '\E_USER_ERROR|\E_USER_WARNING|\E_USER_NOTICE|\E_USER_DEPRECATED'],
8888
'wp_unique_id' => ['($prefix is empty ? numeric-string : ($prefix is numeric ? numeric-string : string))'],
8989
'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args' => $cronArgsType],
@@ -182,22 +182,22 @@
182182
'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array<array-key, mixed> : (\$output is 'ARRAY_N' ? list<mixed> : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => '0|positive-int'],
183183
'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? list<array<array-key, mixed>> : (\$output is 'ARRAY_N' ? list<array<int, mixed>> : (\$output is 'OBJECT_K' ? array<array-key, \stdClass> : list<\stdClass>)))", 'output' => "'OBJECT'|'OBJECT_K'|'ARRAY_A'|'ARRAY_N'"],
184184
'get_bookmark' => ["null|(\$output is 'ARRAY_A' ? array<string, mixed> : (\$output is 'ARRAY_N' ? array<int, mixed> : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"],
185-
'get_categories' => ["(\$args is array{fields: 'count'} ? list<numeric-string> : (\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'} ? list<int> : array<int, \WP_Term>)))))"],
185+
'get_categories' => ["(\$args is array{fields: 'count'}&array ? list<numeric-string> : (\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list<int> : array<int, \WP_Term>)))))"],
186186
'get_category' => ["(\$category is object ? array<array-key, mixed>|\WP_Term : array<array-key, mixed>|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array<string, mixed>|\WP_Error|null : (\$output is 'ARRAY_N' ? array<int, mixed>|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"],
187187
'get_category_by_path' => ["(\$output is 'ARRAY_A' ? array<string, mixed>|\WP_Error|null : (\$output is 'ARRAY_N' ? array<int, mixed>|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"],
188188
'WP_Widget' => [null, '@phpstan-template' => 'T of array<string, mixed>'],
189189
'WP_Widget::form' => [null, 'instance' => 'T'],
190190
'WP_Widget::update' => [null, 'new_instance' => 'T', 'old_instance' => 'T'],
191191
'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}'],
192-
'get_approved_comments' => ["(\$args is array{count: true} ? int : (\$args is array{fields: 'ids'} ? array<int, int> : array<int, \WP_Comment>))"],
193-
'get_posts' => ["(\$args is array{fields: 'id=>parent'|'ids'} ? array<int, int> : array<int, \WP_Post>)"],
194-
'get_sites' => ["(\$args is array{count: true} ? int : (\$args is array{fields: 'ids'} ? array<int, int> : array<int, \WP_Site>))"],
195-
'get_tags' => ["(\$args is array{fields: 'count'} ? numeric-string : (\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'} ? list<int> : array<int, \WP_Term>)))))|\WP_Error"],
196-
'get_terms' => ["(\$args is array{fields: 'count'} ? numeric-string : (\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'} ? list<int> : array<int, \WP_Term>)))))|\WP_Error"],
197-
'wp_get_post_categories' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'all'|'all_with_object_id'} ? array<int, \WP_Term> : (\$args is array{fields: 'count'} ? numeric-string : list<int>)))))|\WP_Error))"],
198-
'wp_get_post_tags' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'} ? list<int> : (\$args is array{fields: 'count'} ? numeric-string : array<int, \WP_Term>)))))|\WP_Error))"],
199-
'wp_get_post_terms' => ["(\$post_id is 0 ? array{} : (\$taxonomy is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'} ? list<int> : (\$args is array{fields: 'count'} ? numeric-string : array<int, \WP_Term>)))))|\WP_Error)))"],
200-
'wp_get_object_terms' => ["(\$object_ids is empty ? array{} : (\$taxonomies is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'} ? array<int, string> : (\$args is array{fields: 'id=>parent'} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'} ? list<int> : (\$args is array{fields: 'count'} ? numeric-string : array<int, \WP_Term>)))))|\WP_Error)))"],
192+
'get_approved_comments' => ["(\$args is array{count: true}&array ? int : (\$args is array{fields: 'ids'}&array ? array<int, int> : array<int, \WP_Comment>))"],
193+
'get_posts' => ["(\$args is array{fields: 'id=>parent'|'ids'}&array ? array<int, int> : array<int, \WP_Post>)"],
194+
'get_sites' => ["(\$args is array{count: true}&array ? int : (\$args is array{fields: 'ids'}&array ? array<int, int> : array<int, \WP_Site>))"],
195+
'get_tags' => ["(\$args is array{fields: 'count'}&array ? numeric-string : (\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list<int> : array<int, \WP_Term>)))))|\WP_Error"],
196+
'get_terms' => ["(\$args is array{fields: 'count'}&array ? numeric-string : (\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list<int> : array<int, \WP_Term>)))))|\WP_Error"],
197+
'wp_get_post_categories' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'all'|'all_with_object_id'}&array ? array<int, \WP_Term> : (\$args is array{fields: 'count'}&array ? numeric-string : list<int>)))))|\WP_Error))"],
198+
'wp_get_post_tags' => ["(\$post_id is 0 ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list<int> : (\$args is array{fields: 'count'}&array ? numeric-string : array<int, \WP_Term>)))))|\WP_Error))"],
199+
'wp_get_post_terms' => ["(\$post_id is 0 ? array{} : (\$taxonomy is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list<int> : (\$args is array{fields: 'count'}&array ? numeric-string : array<int, \WP_Term>)))))|\WP_Error)))"],
200+
'wp_get_object_terms' => ["(\$object_ids is empty ? array{} : (\$taxonomies is empty ? array{} : ((\$args is array{fields: 'names'|'slugs'}&array ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug'}&array ? array<int, string> : (\$args is array{fields: 'id=>parent'}&array ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids'}&array ? list<int> : (\$args is array{fields: 'count'}&array ? numeric-string : array<int, \WP_Term>)))))|\WP_Error)))"],
201201
'wp_json_encode' => ['non-empty-string|false', 'depth' => 'positive-int'],
202202
'wp_parse_list' => ['($input_list is array ? array<scalar> : list<string>)'],
203203
'wp_parse_str' => [null, '@phpstan-param-out' => 'array<int|string, array|string> $result'],

0 commit comments

Comments
 (0)