Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update integer ranges #253

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
'__return_empty_array' => ['array{}'],
'__return_empty_string' => ["''"],
'__return_zero' => ['0'],
'_wp_json_sanity_check' => ['T', '@phpstan-template' => 'T', 'value' => 'T', 'depth' => 'positive-int'],
'_wp_json_sanity_check' => ['T', '@phpstan-template' => 'T', 'value' => 'T', 'depth' => 'int<1, max>'],
'_get_list_table' => ["(\$class_name is 'WP_Posts_List_Table'|'WP_Media_List_Table'|'WP_Terms_List_Table'|'WP_Users_List_Table'|'WP_Comments_List_Table'|'WP_Post_Comments_List_Table'|'WP_Links_List_Table'|'WP_Plugin_Install_List_Table'|'WP_Themes_List_Table'|'WP_Theme_Install_List_Table'|'WP_Plugins_List_Table'|'WP_Application_Passwords_List_Table'|'WP_MS_Sites_List_Table'|'WP_MS_Users_List_Table'|'WP_MS_Themes_List_Table'|'WP_Privacy_Data_Export_Requests_List_Table'|'WP_Privacy_Data_Removal_Requests_List_Table' ? T : false)", '@phpstan-template' => 'T', 'class_name' => 'class-string<T>', 'args' => 'array{screen?: string}'],
'absint' => ['($maybeint is T&non-negative-int ? T : ($maybeint is negative-int ? positive-int : ($maybeint is empty ? 0 : ($maybeint is numeric-string ? non-negative-int : ($maybeint is string ? 0 : ($maybeint is true|non-empty-array ? 1 : ($maybeint is bool ? 0|1 : non-negative-int)))))))', '@phpstan-template T' => 'of int', 'maybeint' => 'T|scalar|array|resource|null'],
'absint' => ['($maybeint is T&int<0, max> ? T : ($maybeint is int<min, -1> ? int<1, max> : ($maybeint is empty ? 0 : ($maybeint is numeric-string ? int<0, max> : ($maybeint is string ? 0 : ($maybeint is true|non-empty-array ? 1 : ($maybeint is bool ? 0|1 : int<0, max>)))))))', '@phpstan-template T' => 'of int', 'maybeint' => 'T|scalar|array|resource|null'],
'addslashes_gpc' => ['T', '@phpstan-template' => 'T', 'gpc' => 'T'],
'add_submenu_page' => [null, 'callback' => "''|callable"],
'bool_from_yn' => ["(\$yn is 'y' ? true : false)"],
Expand All @@ -55,7 +55,7 @@
'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"],
'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_clear_scheduled_hook' => ['(0|int<1, max>|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType],
'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'}&array ? array<int, string> : string)"],
'wp_get_schedule' => [null, 'args' => $cronArgsType],
'wp_get_scheduled_event' => [null, 'args' => $cronArgsType],
Expand Down Expand Up @@ -147,12 +147,12 @@
'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)'],
'wp_insert_attachment' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'],
'wp_update_post' => ['($wp_error is false ? 0|positive-int : positive-int|\WP_Error)'],
'wp_unschedule_hook' => ['($wp_error is false ? 0|positive-int|false : 0|positive-int|\WP_Error)'],
'wp_insert_link' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
'wp_insert_category' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
'wp_insert_post' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
'wp_insert_attachment' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
'wp_update_post' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
'wp_unschedule_hook' => ['($wp_error is false ? 0|int<1, max>|false : 0|int<1, max>|\WP_Error)'],
'wp_update_comment' => ['($wp_error is false ? 0|1|false : 0|1|\WP_Error)'],
'wp_set_comment_status' => ['($wp_error is false ? bool : true|\WP_Error)'],
'comment_class' => ['($display is true ? void : string)'],
Expand All @@ -179,7 +179,7 @@
'WP_Filesystem_SSH2::dirlist' => [$filesystemDirlistReturnType],
'WP_Filesystem_ftpsockets::dirlist' => [$filesystemDirlistReturnType],
'wpdb::prepare' => [null, 'query' => 'literal-string'],
'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'],
'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|int<1, max>'],
'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'"],
'get_bookmark' => ["null|(\$output is 'ARRAY_A' ? array<string, mixed> : (\$output is 'ARRAY_N' ? array<int, mixed> : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"],
'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>)))))"],
Expand All @@ -198,16 +198,16 @@
'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))"],
'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)))"],
'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)))"],
'wp_json_encode' => ['non-empty-string|false', 'depth' => 'positive-int'],
'wp_json_encode' => ['non-empty-string|false', 'depth' => 'int<1, max>'],
'wp_parse_list' => ['($input_list is array ? array<scalar> : list<string>)'],
'wp_parse_str' => [null, '@phpstan-param-out' => 'array<int|string, array|string> $result'],
'size_format' => ["(\$bytes is not numeric ? false : (\$bytes is negative-int|'0' ? false : string))"],
'size_format' => ["(\$bytes is not numeric ? false : (\$bytes is int<min, -1>|'0' ? false : string))"],
'WP_Translations::translate' => ['($singular is null ? null : string)'],
'WP_Translations::translate_plural' => ['($singular is null ? null : ($plural is null ? T : string))', '@phpstan-template T' => 'of string|null', 'singular' => 'T', 'count' => 'int'],
'WP_Query' => [null, '@phpstan-property-read bool $query_vars_changed' => '', '@phpstan-property-read bool|string $query_vars_hash' => '', '@phpstan-method void init_query_flags()' => ''],
'WP_Widget_Factory::$widgets' => [null, '@phpstan-var' => 'array<string, \WP_Widget>'],
'WP_Widget_Factory::register' => [null, 'widget' => 'class-string<\WP_Widget>|\WP_Widget'],
'WP_Widget_Factory::unregister' => [null, 'widget' => 'class-string<\WP_Widget>|\WP_Widget'],
'Custom_Image_Header::show_header_selector' => [null, 'type' => "'default'|'uploaded'"],
'Custom_Image_Header::set_header_image' => [null, 'choice' => 'string|array{attachment_id: positive-int, url: string, width: non-negative-int, height: non-negative-int}'],
'Custom_Image_Header::set_header_image' => [null, 'choice' => 'string|array{attachment_id: int<1, max>, url: string, width: int<0, max>, height: int<0, max>}'],
];
26 changes: 13 additions & 13 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ public function filter_upload_tabs($tabs)
* registered for that theme; and the key of an image uploaded for that theme
* (the attachment ID of the image). Or an array of arguments: attachment_id,
* url, width, height. All are required.
* @phpstan-param string|array{attachment_id: positive-int, url: string, width: non-negative-int, height: non-negative-int} $choice
* @phpstan-param string|array{attachment_id: int<1, max>, url: string, width: int<0, max>, height: int<0, max>} $choice
* @phpstan-return void
*/
public final function set_header_image($choice)
Expand Down Expand Up @@ -57879,7 +57879,7 @@ public function get_var($query = \null, $x = 0, $y = 0)
* @param int $y Optional. Row to return. Indexed from 0. Default 0.
* @return array|object|null|void Database query result in format specified by $output or null on failure.
* @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output
* @phpstan-param 0|positive-int $y
* @phpstan-param 0|int<1, max> $y
* @phpstan-return null|void|($output is 'ARRAY_A' ? array<array-key, mixed> : ($output is 'ARRAY_N' ? list<mixed> : \stdClass))
*/
public function get_row($query = \null, $output = \OBJECT, $y = 0)
Expand Down Expand Up @@ -79481,7 +79481,7 @@ function get_link_to_edit($link)
* link_rss?: string,
* link_category?: int,
* } $linkdata
* @phpstan-return ($wp_error is false ? 0|positive-int : positive-int|\WP_Error)
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
*/
function wp_insert_link($linkdata, $wp_error = \false)
{
Expand Down Expand Up @@ -86498,7 +86498,7 @@ function wp_create_categories($categories, $post_id = '')
* category_nicename?: string,
* category_parent?: int|string,
* } $catarr
* @phpstan-return ($wp_error is false ? 0|positive-int : positive-int|\WP_Error)
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
*/
function wp_insert_category($catarr, $wp_error = \false)
{
Expand Down Expand Up @@ -100276,7 +100276,7 @@ function wp_unschedule_event($timestamp, $hook, $args = array(), $wp_error = \fa
* events were registered with the hook and arguments combination), false or WP_Error
* if unscheduling one or more events fail.
* @phpstan-param list<mixed> $args
* @phpstan-return (0|positive-int|($wp_error is false ? false : \WP_Error))
* @phpstan-return (0|int<1, max>|($wp_error is false ? false : \WP_Error))
*/
function wp_clear_scheduled_hook($hook, $args = array(), $wp_error = \false)
{
Expand All @@ -100299,7 +100299,7 @@ function wp_clear_scheduled_hook($hook, $args = array(), $wp_error = \false)
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
* @return int|false|WP_Error On success an integer indicating number of events unscheduled (0 indicates no
* events were registered on the hook), false or WP_Error if unscheduling fails.
* @phpstan-return ($wp_error is false ? 0|positive-int|false : 0|positive-int|\WP_Error)
* @phpstan-return ($wp_error is false ? 0|int<1, max>|false : 0|int<1, max>|\WP_Error)
*/
function wp_unschedule_hook($hook, $wp_error = \false)
{
Expand Down Expand Up @@ -107562,7 +107562,7 @@ function number_format_i18n($number, $decimals = 0)
* @param int|string $bytes Number of bytes. Note max integer size for integers.
* @param int $decimals Optional. Precision of number of decimal places. Default 0.
* @return string|false Number string on success, false on failure.
* @phpstan-return ($bytes is not numeric ? false : ($bytes is negative-int|'0' ? false : string))
* @phpstan-return ($bytes is not numeric ? false : ($bytes is int<min, -1>|'0' ? false : string))
*/
function size_format($bytes, $decimals = 0)
{
Expand Down Expand Up @@ -108849,7 +108849,7 @@ function _wp_die_process_input($message, $title = '', $args = array())
* @param int $depth Optional. Maximum depth to walk through $value. Must be
* greater than 0. Default 512.
* @return string|false The JSON encoded string, or false if it cannot be encoded.
* @phpstan-param positive-int $depth
* @phpstan-param int<1, max> $depth
* @phpstan-return non-empty-string|false
*/
function wp_json_encode($value, $flags = 0, $depth = 512)
Expand All @@ -108871,7 +108871,7 @@ function wp_json_encode($value, $flags = 0, $depth = 512)
* @return mixed The sanitized data that shall be encoded to JSON.
* @phpstan-template T
* @phpstan-param T $value
* @phpstan-param positive-int $depth
* @phpstan-param int<1, max> $depth
* @phpstan-return T
*/
function _wp_json_sanity_check($value, $depth)
Expand Down Expand Up @@ -109454,7 +109454,7 @@ function dead_db()
* @return int A non-negative integer.
* @phpstan-template T of int
* @phpstan-param T|scalar|array|resource|null $maybeint
* @phpstan-return ($maybeint is T&non-negative-int ? T : ($maybeint is negative-int ? positive-int : ($maybeint is empty ? 0 : ($maybeint is numeric-string ? non-negative-int : ($maybeint is string ? 0 : ($maybeint is true|non-empty-array ? 1 : ($maybeint is bool ? 0|1 : non-negative-int)))))))
* @phpstan-return ($maybeint is T&int<0, max> ? T : ($maybeint is int<min, -1> ? int<1, max> : ($maybeint is empty ? 0 : ($maybeint is numeric-string ? int<0, max> : ($maybeint is string ? 0 : ($maybeint is true|non-empty-array ? 1 : ($maybeint is bool ? 0|1 : int<0, max>)))))))
*/
function absint($maybeint)
{
Expand Down Expand Up @@ -128991,7 +128991,7 @@ function wp_get_recent_posts($args = array(), $output = \ARRAY_A)
* meta_input?: array,
* page_template?: string,
* } $postarr
* @phpstan-return ($wp_error is false ? 0|positive-int : positive-int|\WP_Error)
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
*/
function wp_insert_post($postarr, $wp_error = \false, $fire_after_hooks = \true)
{
Expand Down Expand Up @@ -129040,7 +129040,7 @@ function wp_insert_post($postarr, $wp_error = \false, $fire_after_hooks = \true)
* meta_input?: array,
* page_template?: string,
* } $postarr See wp_insert_post()
* @phpstan-return ($wp_error is false ? 0|positive-int : positive-int|\WP_Error)
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
*/
function wp_update_post($postarr = array(), $wp_error = \false, $fire_after_hooks = \true)
{
Expand Down Expand Up @@ -129506,7 +129506,7 @@ function is_local_attachment($url)
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
* @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.
* @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
* @phpstan-return ($wp_error is false ? 0|positive-int : positive-int|\WP_Error)
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
*/
function wp_insert_attachment($args, $file = \false, $parent_post_id = 0, $wp_error = \false, $fire_after_hooks = \true)
{
Expand Down