From 28ea27dba5dec08952b3a2107f63bc81a477fb06 Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Fri, 11 Oct 2024 20:50:48 +0200 Subject: [PATCH 1/2] Update integer ranges in Faker --- tests/Faker.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Faker.php b/tests/Faker.php index 96fd0d6..cecbb79 100644 --- a/tests/Faker.php +++ b/tests/Faker.php @@ -11,11 +11,11 @@ * @method static true true() * @method static false false() * @method static int int() - * @method static positive-int positiveInt() - * @method static negative-int negativeInt() - * @method static non-positive-int nonPositiveInt() - * @method static non-negative-int nonNegativeInt() - * @method static non-zero-int nonZeroInt() + * @method static int<1, max> positiveInt() + * @method static int negativeInt() + * @method static int nonPositiveInt() + * @method static int<0, max> nonNegativeInt() + * @method static int|int<1, max> nonZeroInt() * @method static float float() * @method static string string() * @method static non-empty-string nonEmptyString() From 0d3c74857097bee6d8f87e20858ce0107030e538 Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Fri, 11 Oct 2024 20:58:38 +0200 Subject: [PATCH 2/2] Simplify 0|int<1, max> to int<0, max> --- functionMap.php | 16 ++++++++-------- wordpress-stubs.php | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/functionMap.php b/functionMap.php index 04c90f6..69e0b24 100644 --- a/functionMap.php +++ b/functionMap.php @@ -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|int<1, max>|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType], + 'wp_clear_scheduled_hook' => ['(int<0, max>|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType], '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], @@ -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|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_insert_link' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'], + 'wp_insert_category' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'], + 'wp_insert_post' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'], + 'wp_insert_attachment' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'], + 'wp_update_post' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'], + 'wp_unschedule_hook' => ['($wp_error is false ? int<0, max>|false : int<0, 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)'], @@ -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 : (\$output is 'ARRAY_N' ? list : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => '0|int<1, max>'], + 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? list : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => 'int<0, max>'], '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'}&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)))))"], diff --git a/wordpress-stubs.php b/wordpress-stubs.php index ca5a790..88476e1 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -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|int<1, max> $y + * @phpstan-param int<0, max> $y * @phpstan-return null|void|($output is 'ARRAY_A' ? array : ($output is 'ARRAY_N' ? list : \stdClass)) */ public function get_row($query = \null, $output = \OBJECT, $y = 0) @@ -79481,7 +79481,7 @@ function get_link_to_edit($link) * link_rss?: string, * link_category?: int, * } $linkdata - * @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error) + * @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error) */ function wp_insert_link($linkdata, $wp_error = \false) { @@ -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|int<1, max> : int<1, max>|\WP_Error) + * @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error) */ function wp_insert_category($catarr, $wp_error = \false) { @@ -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 $args - * @phpstan-return (0|int<1, max>|($wp_error is false ? false : \WP_Error)) + * @phpstan-return (int<0, max>|($wp_error is false ? false : \WP_Error)) */ function wp_clear_scheduled_hook($hook, $args = array(), $wp_error = \false) { @@ -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|int<1, max>|false : 0|int<1, max>|\WP_Error) + * @phpstan-return ($wp_error is false ? int<0, max>|false : int<0, max>|\WP_Error) */ function wp_unschedule_hook($hook, $wp_error = \false) { @@ -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|int<1, max> : int<1, max>|\WP_Error) + * @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error) */ function wp_insert_post($postarr, $wp_error = \false, $fire_after_hooks = \true) { @@ -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|int<1, max> : int<1, max>|\WP_Error) + * @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error) */ function wp_update_post($postarr = array(), $wp_error = \false, $fire_after_hooks = \true) { @@ -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|int<1, max> : int<1, max>|\WP_Error) + * @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error) */ function wp_insert_attachment($args, $file = \false, $parent_post_id = 0, $wp_error = \false, $fire_after_hooks = \true) {