Skip to content

Commit e3b8074

Browse files
authored
Update integer ranges (#255)
* Update integer ranges in Faker * Simplify 0|int<1, max> to int<0, max>
1 parent 638b3a3 commit e3b8074

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

functionMap.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
'validate_file' => ["(\$file is '' ? 0 : (\$allowed_files is empty ? 0|1|2 : 0|1|2|3))"],
5656
'wp_die' => ['($args is array{exit: false}&array ? void : never)'],
5757
'wp_dropdown_languages' => ["(\$args is array{id: null|''}&array ? void : (\$args is array{name: null|''}&array ? void : string))"],
58-
'wp_clear_scheduled_hook' => ['(0|int<1, max>|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType],
58+
'wp_clear_scheduled_hook' => ['(int<0, max>|($wp_error is false ? false : \WP_Error))', 'args' => $cronArgsType],
5959
'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],
@@ -147,12 +147,12 @@
147147
'term_exists' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null)))"],
148148
'is_term' => ["(\$term is 0 ? 0 : (\$term is '' ? null : (\$taxonomy is '' ? string|null : array{term_id: string, term_taxonomy_id: string}|null)))"],
149149
'tag_exists' => ["(\$tag_name is 0 ? 0 : (\$tag_name is '' ? null : array{term_id: string, term_taxonomy_id: string}|null))"],
150-
'wp_insert_link' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
151-
'wp_insert_category' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
152-
'wp_insert_post' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
153-
'wp_insert_attachment' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
154-
'wp_update_post' => ['($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)'],
155-
'wp_unschedule_hook' => ['($wp_error is false ? 0|int<1, max>|false : 0|int<1, max>|\WP_Error)'],
150+
'wp_insert_link' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'],
151+
'wp_insert_category' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'],
152+
'wp_insert_post' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'],
153+
'wp_insert_attachment' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'],
154+
'wp_update_post' => ['($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)'],
155+
'wp_unschedule_hook' => ['($wp_error is false ? int<0, max>|false : int<0, max>|\WP_Error)'],
156156
'wp_update_comment' => ['($wp_error is false ? 0|1|false : 0|1|\WP_Error)'],
157157
'wp_set_comment_status' => ['($wp_error is false ? bool : true|\WP_Error)'],
158158
'comment_class' => ['($display is true ? void : string)'],
@@ -179,7 +179,7 @@
179179
'WP_Filesystem_SSH2::dirlist' => [$filesystemDirlistReturnType],
180180
'WP_Filesystem_ftpsockets::dirlist' => [$filesystemDirlistReturnType],
181181
'wpdb::prepare' => [null, 'query' => 'literal-string'],
182-
'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>'],
182+
'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' => 'int<0, max>'],
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'"],
185185
'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>)))))"],

tests/Faker.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
* @method static true true()
1212
* @method static false false()
1313
* @method static int int()
14-
* @method static positive-int positiveInt()
15-
* @method static negative-int negativeInt()
16-
* @method static non-positive-int nonPositiveInt()
17-
* @method static non-negative-int nonNegativeInt()
18-
* @method static non-zero-int nonZeroInt()
14+
* @method static int<1, max> positiveInt()
15+
* @method static int<min, -1> negativeInt()
16+
* @method static int<min, 0> nonPositiveInt()
17+
* @method static int<0, max> nonNegativeInt()
18+
* @method static int<min, -1>|int<1, max> nonZeroInt()
1919
* @method static float float()
2020
* @method static string string()
2121
* @method static non-empty-string nonEmptyString()

wordpress-stubs.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57879,7 +57879,7 @@ public function get_var($query = \null, $x = 0, $y = 0)
5787957879
* @param int $y Optional. Row to return. Indexed from 0. Default 0.
5788057880
* @return array|object|null|void Database query result in format specified by $output or null on failure.
5788157881
* @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output
57882-
* @phpstan-param 0|int<1, max> $y
57882+
* @phpstan-param int<0, max> $y
5788357883
* @phpstan-return null|void|($output is 'ARRAY_A' ? array<array-key, mixed> : ($output is 'ARRAY_N' ? list<mixed> : \stdClass))
5788457884
*/
5788557885
public function get_row($query = \null, $output = \OBJECT, $y = 0)
@@ -79481,7 +79481,7 @@ function get_link_to_edit($link)
7948179481
* link_rss?: string,
7948279482
* link_category?: int,
7948379483
* } $linkdata
79484-
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
79484+
* @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)
7948579485
*/
7948679486
function wp_insert_link($linkdata, $wp_error = \false)
7948779487
{
@@ -86498,7 +86498,7 @@ function wp_create_categories($categories, $post_id = '')
8649886498
* category_nicename?: string,
8649986499
* category_parent?: int|string,
8650086500
* } $catarr
86501-
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
86501+
* @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)
8650286502
*/
8650386503
function wp_insert_category($catarr, $wp_error = \false)
8650486504
{
@@ -100276,7 +100276,7 @@ function wp_unschedule_event($timestamp, $hook, $args = array(), $wp_error = \fa
100276100276
* events were registered with the hook and arguments combination), false or WP_Error
100277100277
* if unscheduling one or more events fail.
100278100278
* @phpstan-param list<mixed> $args
100279-
* @phpstan-return (0|int<1, max>|($wp_error is false ? false : \WP_Error))
100279+
* @phpstan-return (int<0, max>|($wp_error is false ? false : \WP_Error))
100280100280
*/
100281100281
function wp_clear_scheduled_hook($hook, $args = array(), $wp_error = \false)
100282100282
{
@@ -100299,7 +100299,7 @@ function wp_clear_scheduled_hook($hook, $args = array(), $wp_error = \false)
100299100299
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
100300100300
* @return int|false|WP_Error On success an integer indicating number of events unscheduled (0 indicates no
100301100301
* events were registered on the hook), false or WP_Error if unscheduling fails.
100302-
* @phpstan-return ($wp_error is false ? 0|int<1, max>|false : 0|int<1, max>|\WP_Error)
100302+
* @phpstan-return ($wp_error is false ? int<0, max>|false : int<0, max>|\WP_Error)
100303100303
*/
100304100304
function wp_unschedule_hook($hook, $wp_error = \false)
100305100305
{
@@ -128991,7 +128991,7 @@ function wp_get_recent_posts($args = array(), $output = \ARRAY_A)
128991128991
* meta_input?: array,
128992128992
* page_template?: string,
128993128993
* } $postarr
128994-
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
128994+
* @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)
128995128995
*/
128996128996
function wp_insert_post($postarr, $wp_error = \false, $fire_after_hooks = \true)
128997128997
{
@@ -129040,7 +129040,7 @@ function wp_insert_post($postarr, $wp_error = \false, $fire_after_hooks = \true)
129040129040
* meta_input?: array,
129041129041
* page_template?: string,
129042129042
* } $postarr See wp_insert_post()
129043-
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
129043+
* @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)
129044129044
*/
129045129045
function wp_update_post($postarr = array(), $wp_error = \false, $fire_after_hooks = \true)
129046129046
{
@@ -129506,7 +129506,7 @@ function is_local_attachment($url)
129506129506
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
129507129507
* @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.
129508129508
* @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure.
129509-
* @phpstan-return ($wp_error is false ? 0|int<1, max> : int<1, max>|\WP_Error)
129509+
* @phpstan-return ($wp_error is false ? int<0, max> : int<1, max>|\WP_Error)
129510129510
*/
129511129511
function wp_insert_attachment($args, $file = \false, $parent_post_id = 0, $wp_error = \false, $fire_after_hooks = \true)
129512129512
{

0 commit comments

Comments
 (0)