|
13 | 13 | /** |
14 | 14 | * This array is in the same format as the function map array in PHPStan: |
15 | 15 | * |
16 | | - * '<function_name>' => ['<return_type>', '<arg_name>'=>'<arg_type>'] |
| 16 | + * '<function_name>' => ['<return_type>', '<arg_name>' => '<arg_type>'] |
17 | 17 | * |
18 | 18 | * For classes, or if you don't wish to define the `@phpstan-return` tag: |
19 | 19 | * |
20 | | - * '<class_name>' => [null, '<arg_name>'=>'<arg_type>'] |
| 20 | + * '<class_name>' => [null, '<arg_name>' => '<arg_type>'] |
21 | 21 | * |
22 | | - * @link https://github.com/phpstan/phpstan-src/blob/1.5.x/resources/functionMap.php |
| 22 | + * @link https://github.com/phpstan/phpstan-src/blob/1.10.x/resources/functionMap.php |
23 | 23 | */ |
24 | 24 | return [ |
25 | | - 'addslashes_gpc' => ['T', '@phpstan-template'=>'T', 'gpc'=>'T'], |
26 | | - 'get_objects_in_term' => [null, 'args'=>'array{order?: string}'], |
27 | | - 'have_posts' => [null, '@phpstan-impure'=>''], |
28 | | - 'rawurlencode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], |
29 | | - 'sanitize_category' => ['T', '@phpstan-template'=>'T of array|object', 'category'=>'T'], |
30 | | - 'sanitize_post' => ['T', '@phpstan-template'=>'T of array|object', 'post'=>'T'], |
31 | | - 'sanitize_term' => ['T', '@phpstan-template'=>'T of array|object', 'term'=>'T'], |
32 | | - 'stripslashes_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], |
33 | | - 'urldecode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], |
34 | | - 'urlencode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], |
35 | | - 'wp_clear_scheduled_hook' => ['($wp_error is false ? 0|positive-int|false : 0|positive-int|\WP_Error)', 'args'=>$cronArgsType], |
| 25 | + 'addslashes_gpc' => ['T', '@phpstan-template' => 'T', 'gpc' => 'T'], |
| 26 | + 'get_objects_in_term' => [null, 'args' => 'array{order?: string}'], |
| 27 | + 'have_posts' => [null, '@phpstan-impure' => ''], |
| 28 | + 'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], |
| 29 | + 'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'], |
| 30 | + 'sanitize_post' => ['T', '@phpstan-template' => 'T of array|object', 'post' => 'T'], |
| 31 | + 'sanitize_term' => ['T', '@phpstan-template' => 'T of array|object', 'term' => 'T'], |
| 32 | + 'stripslashes_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], |
| 33 | + 'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], |
| 34 | + 'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], |
| 35 | + 'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args'=>$cronArgsType], |
36 | 36 | 'wp_get_schedule' => [null, 'args'=>$cronArgsType], |
37 | 37 | 'wp_get_scheduled_event' => [null, 'args'=>$cronArgsType], |
38 | 38 | 'WP_Http::get' => [$httpReturnType], |
39 | 39 | 'WP_Http::head' => [$httpReturnType], |
40 | 40 | 'WP_Http::post' => [$httpReturnType], |
41 | 41 | 'WP_Http::request' => [$httpReturnType], |
42 | | - 'WP_List_Table::display_tablenav' => ['void', 'which'=>'"top"|"bottom"'], |
43 | | - 'WP_List_Table::pagination' => ['void', 'which'=>'"top"|"bottom"'], |
44 | | - 'WP_List_Table::set_pagination_args' => ['void', 'args'=>'array{total_items?: int, total_pages?: int, per_page?: int}'], |
| 42 | + 'WP_List_Table::display_tablenav' => ['void', 'which' => '"top"|"bottom"'], |
| 43 | + 'WP_List_Table::pagination' => ['void', 'which' => '"top"|"bottom"'], |
| 44 | + 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'], |
45 | 45 | 'wp_next_scheduled' => [null, 'args'=>$cronArgsType], |
46 | | - 'WP_Post_Type::__construct' => ['void', 'args'=>'array<string, mixed>'], |
47 | | - 'WP_Query::have_posts' => [null, '@phpstan-impure'=>''], |
| 46 | + 'WP_Query::have_posts' => [null, '@phpstan-impure' => ''], |
48 | 47 | 'wp_remote_get' => [$httpReturnType], |
49 | 48 | 'wp_remote_head' => [$httpReturnType], |
50 | 49 | 'wp_remote_post' => [$httpReturnType], |
|
56 | 55 | 'wp_safe_remote_request' => [$httpReturnType], |
57 | 56 | 'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], |
58 | 57 | 'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], |
59 | | - 'wp_slash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], |
60 | | - 'WP_Taxonomy::__construct' => ['void', 'args'=>'array<string, mixed>'], |
| 58 | + 'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], |
61 | 59 | 'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], |
62 | | - 'wp_unslash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], |
| 60 | + 'wp_unslash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], |
63 | 61 | 'wp_widget_rss_form' => ['void', 'args'=>$wpWidgetRssFormArgsType, 'input'=>$wpWidgetRssFormInputType], |
64 | | - 'WP_REST_Request' => [null, '@phpstan-template'=>'T of array', '@phpstan-implements'=>'ArrayAccess<key-of<T>, value-of<T>>'], |
65 | | - 'WP_REST_Request::offsetExists' => [null, 'offset'=>'@param key-of<T>'], |
66 | | - 'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template'=>'TOffset of key-of<T>', 'offset'=>'TOffset'], |
67 | | - 'WP_REST_Request::offsetSet' => ['void', '@phpstan-template'=>'TOffset of key-of<T>', 'offset'=>'TOffset', 'value'=>'T[TOffset]'], |
68 | | - 'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template'=>'TOffset of key-of<T>', 'offset'=>'TOffset'], |
| 62 | + 'WP_REST_Request' => [null, '@phpstan-template' => 'T of array', '@phpstan-implements' => 'ArrayAccess<key-of<T>, value-of<T>>'], |
| 63 | + 'WP_REST_Request::offsetExists' => [null, 'offset' => '@param key-of<T>'], |
| 64 | + 'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset'], |
| 65 | + 'WP_REST_Request::offsetSet' => ['void', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset', 'value' => 'T[TOffset]'], |
| 66 | + 'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template' => 'TOffset of key-of<T>', 'offset' => 'TOffset'], |
69 | 67 | 'WP_Theme' => [null, '@phpstan-type'=>"ThemeKey 'Name'|'Version'|'Status'|'Title'|'Author'|'Author Name'|'Author URI'|'Description'|'Template'|'Stylesheet'|'Template Files'|'Stylesheet Files'|'Template Dir'|'Stylesheet Dir'|'Screenshot'|'Tags'|'Theme Root'|'Theme Root URI'|'Parent Theme'"], |
70 | 68 | 'WP_Theme::get' => ["(\$header is 'Name'|'ThemeURI'|'Description'|'Author'|'AuthorURI'|'Version'|'Template'|'Status'|'Tags'|'TextDomain'|'DomainPath'|'RequiresWP'|'RequiresPHP'|'UpdateURI' ? (\$header is 'Tags' ? string[] : string) : false)"], |
71 | 69 | 'WP_Theme::offsetExists' => ['($offset is ThemeKey ? true : false)'], |
72 | 70 | 'WP_Theme::offsetGet' => ['($offset is ThemeKey ? mixed : null)'], |
73 | | - 'WP_Block_List' => [null, '@phpstan-implements'=>'ArrayAccess<int, WP_Block>'], |
74 | | - 'WP_Block_List::offsetExists' => [null, 'index'=>'int'], |
75 | | - 'WP_Block_List::offsetGet' => ['WP_Block|null', 'index'=>'int'], |
76 | | - 'WP_Block_List::offsetSet' => ['void', 'index'=>'int|null'], |
77 | | - 'WP_Block_List::offsetUnset' => ['void', 'index'=>'int'], |
78 | | - 'is_wp_error' => ['($thing is \WP_Error ? true : false)', '@phpstan-assert-if-true'=>'\WP_Error $thing'], |
| 71 | + 'WP_Block_List' => [null, '@phpstan-implements' => 'ArrayAccess<int, WP_Block>'], |
| 72 | + 'WP_Block_List::offsetExists' => [null, 'index' => 'int'], |
| 73 | + 'WP_Block_List::offsetGet' => ['WP_Block|null', 'index' => 'int'], |
| 74 | + 'WP_Block_List::offsetSet' => ['void', 'index' => 'int|null'], |
| 75 | + 'WP_Block_List::offsetUnset' => ['void', 'index' => 'int'], |
| 76 | + 'is_wp_error' => ['($thing is \WP_Error ? true : false)', '@phpstan-assert-if-true' => '\WP_Error $thing'], |
79 | 77 | 'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"], |
80 | 78 | 'mysql2date' => ["(\$format is 'G'|'U' ? int|false : string|false)"], |
81 | 79 | 'get_post_types' => ["(\$output is 'names' ? array<int, string> : array<int, \WP_Post_Type>)"], |
|
84 | 82 | 'get_attachment_taxonomies' => ["(\$output is 'names' ? array<int, string> : array<string, \WP_Taxonomy>)"], |
85 | 83 | 'get_taxonomies_for_attachments' => ["(\$output is 'names' ? array<int, string> : array<string, \WP_Taxonomy>)"], |
86 | 84 | 'get_post_stati' => ["(\$output is 'names' ? array<string, string> : array<string, \stdClass>)"], |
87 | | - 'get_comment' => ["(\$output is 'ARRAY_A' ? array<string, mixed>|null : (\$output is 'ARRAY_N' ? array<int, mixed>|null : \WP_Comment|null))"], |
88 | | - 'get_post' => ["(\$output is 'ARRAY_A' ? array<string, mixed>|null : (\$output is 'ARRAY_N' ? array<int, mixed>|null : \WP_Post|null))"], |
| 85 | + 'get_comment' => ["(\$comment is \WP_Comment ? array<array-key, mixed>|\WP_Comment : array<array-key, mixed>|\WP_Comment|null) & (\$output is 'ARRAY_A' ? array<string, mixed>|null : (\$output is 'ARRAY_N' ? array<int, mixed>|null : \WP_Comment|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'"], |
| 86 | + 'get_post' => ["(\$post is \WP_Post ? array<array-key, mixed>|\WP_Post : array<array-key, mixed>|\WP_Post|null) & (\$output is 'ARRAY_A' ? array<string, mixed>|null : (\$output is 'ARRAY_N' ? array<int, mixed>|null : \WP_Post|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'" ], |
89 | 87 | 'get_term_by' => ["(\$output is 'ARRAY_A' ? array<string, string|int>|\WP_Error|false : (\$output is 'ARRAY_N' ? list<string|int>|\WP_Error|false : \WP_Term|\WP_Error|false))"], |
90 | 88 | 'get_page_by_path' => ["(\$output is 'ARRAY_A' ? array<string, mixed>|null : (\$output is 'ARRAY_N' ? array<int, mixed>|null : \WP_Post|null))"], |
91 | | - 'get_term' => ["(\$output is 'ARRAY_A' ? array<string, string|int>|\WP_Error|null : (\$output is 'ARRAY_N' ? list<string|int>|\WP_Error|null : \WP_Term|\WP_Error|null))"], |
| 89 | + 'get_term' => ["(\$output is 'ARRAY_A' ? array<string, string|int>|\WP_Error|null : (\$output is 'ARRAY_N' ? list<string|int>|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'"], |
92 | 90 | 'has_action' => ['($callback is false ? bool : false|int)'], |
93 | 91 | 'has_filter' => ['($callback is false ? bool : false|int)'], |
94 | 92 | 'get_permalink' => ['($post is \WP_Post ? string : string|false)'], |
|
127 | 125 | 'WP_Filesystem_Base::dirlist' => [$filesystemDirlistReturnType], |
128 | 126 | 'WP_Filesystem_SSH2::dirlist' => [$filesystemDirlistReturnType], |
129 | 127 | 'WP_Filesystem_ftpsockets::dirlist' => [$filesystemDirlistReturnType], |
130 | | - 'wpdb::prepare' => [null, 'query'=>'literal-string'], |
| 128 | + 'wpdb::prepare' => [null, 'query' => 'literal-string'], |
| 129 | + 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array<string, mixed> : (\$output is 'ARRAY_N' ? array<int, mixed> : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => '0|positive-int'], |
| 130 | + 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array<string, mixed> : (\$output is 'ARRAY_N' ? array<int, mixed> : (\$output is 'OBJECT_K' ? array<string, \stdClass> : \stdClass)))", 'output' => "'OBJECT'|'OBJECT_K'|'ARRAY_A'|'ARRAY_N'"], |
| 131 | + 'get_bookmark' => ["null|(\$output is 'ARRAY_A' ? array<string, mixed> : (\$output is 'ARRAY_N' ? array<int, mixed> : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], |
| 132 | + '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'"], |
| 133 | + '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'"], |
131 | 134 | ]; |
0 commit comments