From 05d15e680b2f674ff6a06231299f211af1983a9c Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:15:35 +0100 Subject: [PATCH 01/13] Improve return type of get_comment() and get_post() --- functionMap.php | 4 ++-- tests/data/get_comment.php | 20 +++++++++++--------- tests/data/get_post.php | 18 ++++++++++-------- wordpress-stubs.php | 6 ++++-- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/functionMap.php b/functionMap.php index b73efa5..3c7e31f 100644 --- a/functionMap.php +++ b/functionMap.php @@ -84,8 +84,8 @@ 'get_attachment_taxonomies' => ["(\$output is 'names' ? array : array)"], 'get_taxonomies_for_attachments' => ["(\$output is 'names' ? array : array)"], 'get_post_stati' => ["(\$output is 'names' ? array : array)"], - 'get_comment' => ["(\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Comment|null))"], - 'get_post' => ["(\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Post|null))"], + 'get_comment' => ["(\$comment is \WP_Comment ? array|\WP_Comment : array|\WP_Comment|null) & (\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Comment|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'"], + 'get_post' => ["(\$post is \WP_Post ? array|\WP_Post : array|\WP_Post|null) & (\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Post|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'" ], 'get_term_by' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|false : (\$output is 'ARRAY_N' ? list|\WP_Error|false : \WP_Term|\WP_Error|false))"], 'get_page_by_path' => ["(\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Post|null))"], 'get_term' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? list|\WP_Error|null : \WP_Term|\WP_Error|null))"], diff --git a/tests/data/get_comment.php b/tests/data/get_comment.php index e38228b..f0bcc77 100644 --- a/tests/data/get_comment.php +++ b/tests/data/get_comment.php @@ -7,22 +7,24 @@ use function get_comment; use function PHPStan\Testing\assertType; -/** @var \WP_Comment|int $comment */ -$comment = $comment; +/** @var \WP_Comment|int|string|null $comment */ +$comment; // Default output assertType('WP_Comment|null', get_comment()); assertType('WP_Comment|null', get_comment($comment)); -assertType('WP_Comment|null', get_comment($comment, OBJECT)); +assertType('WP_Comment|null', get_comment($comment, 'OBJECT')); // Associative array output -assertType('array|null', get_comment($comment, ARRAY_A)); +assertType('array|null', get_comment($comment, 'ARRAY_A')); // Numeric array output -assertType('array|null', get_comment($comment, ARRAY_N)); +assertType('array|null', get_comment($comment, 'ARRAY_N')); -// Unknown output -assertType('array|WP_Comment|null', get_comment($comment, (string)$_GET['unknown_string'])); +/** @var \WP_Comment $comment */ +$comment; -// Unexpected output -assertType('WP_Comment|null', get_comment($comment, 'Hello')); +assertType('WP_Comment', get_comment($comment)); +assertType('WP_Comment', get_comment($comment, 'OBJECT')); +assertType('array', get_comment($comment, 'ARRAY_A')); +assertType('array', get_comment($comment, 'ARRAY_N')); diff --git a/tests/data/get_post.php b/tests/data/get_post.php index 5766f85..8061772 100644 --- a/tests/data/get_post.php +++ b/tests/data/get_post.php @@ -8,21 +8,23 @@ use function PHPStan\Testing\assertType; /** @var \WP_Post|int|null $post */ -$post = $post; +$post; // Default output assertType('WP_Post|null', get_post()); assertType('WP_Post|null', get_post($post)); -assertType('WP_Post|null', get_post($post, OBJECT)); +assertType('WP_Post|null', get_post($post, 'OBJECT')); // Associative array output -assertType('array|null', get_post($post, ARRAY_A)); +assertType('array|null', get_post($post, 'ARRAY_A')); // Numeric array output -assertType('array|null', get_post($post, ARRAY_N)); +assertType('array|null', get_post($post, 'ARRAY_N')); -// Unknown output -assertType('array|WP_Post|null', get_post($post, (string)$_GET['unknown_string'])); +/** @var \WP_Post $post */ +$post; -// Unexpected output -assertType('WP_Post|null', get_post($post, 'Hello')); +assertType('WP_Post', get_post($post)); +assertType('WP_Post', get_post($post, 'OBJECT')); +assertType('array', get_post($post, 'ARRAY_A')); +assertType('array', get_post($post, 'ARRAY_N')); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 7dba24e..1d9cf55 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -95462,7 +95462,8 @@ function get_approved_comments($post_id, $args = array()) * correspond to a WP_Comment object, an associative array, or a numeric array, * respectively. Default OBJECT. * @return WP_Comment|array|null Depends on $output value. - * @phpstan-return ($output is 'ARRAY_A' ? array|null : ($output is 'ARRAY_N' ? array|null : \WP_Comment|null)) + * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output + * @phpstan-return ($comment is \WP_Comment ? array|\WP_Comment : array|\WP_Comment|null) & ($output is 'ARRAY_A' ? array|null : ($output is 'ARRAY_N' ? array|null : \WP_Comment|null)) */ function get_comment($comment = \null, $output = \OBJECT) { @@ -122966,7 +122967,8 @@ function get_extended($post) * @return WP_Post|array|null Type corresponding to $output on success or null on failure. * When $output is OBJECT, a `WP_Post` instance is returned. * @phpstan-param 'raw'|'edit'|'db'|'display' $filter - * @phpstan-return ($output is 'ARRAY_A' ? array|null : ($output is 'ARRAY_N' ? array|null : \WP_Post|null)) + * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output + * @phpstan-return ($post is \WP_Post ? array|\WP_Post : array|\WP_Post|null) & ($output is 'ARRAY_A' ? array|null : ($output is 'ARRAY_N' ? array|null : \WP_Post|null)) */ function get_post($post = \null, $output = \OBJECT, $filter = 'raw') { From 33a692c582d25e349ef074311447095456ee7918 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:05:07 +0100 Subject: [PATCH 02/13] Add wpdb::get_row() to functions map --- functionMap.php | 1 + tests/TypeInferenceTest.php | 1 + tests/data/wpdb.php | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/data/wpdb.php diff --git a/functionMap.php b/functionMap.php index 3c7e31f..8c1bdd8 100644 --- a/functionMap.php +++ b/functionMap.php @@ -128,4 +128,5 @@ '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' ? array : \stdClass))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], ]; diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 010717e..63f620a 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -29,6 +29,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/term_exists.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_error_parameter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_theme.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wpdb.php'); } /** diff --git a/tests/data/wpdb.php b/tests/data/wpdb.php new file mode 100644 index 0000000..cfdfb77 --- /dev/null +++ b/tests/data/wpdb.php @@ -0,0 +1,14 @@ +|void|null', wpdb::get_row(null, 'ARRAY_A')); +assertType('array|void|null', wpdb::get_row(null, 'ARRAY_N')); From 77c68341eb98cf93fccf2c57dfc81fa8594598aa Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:16:37 +0100 Subject: [PATCH 03/13] Add tests for wp_clear_scheduled_hook() --- functionMap.php | 2 +- tests/TypeInferenceTest.php | 1 + tests/data/wp_clear_scheduled_hook.php | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/data/wp_clear_scheduled_hook.php diff --git a/functionMap.php b/functionMap.php index 8c1bdd8..2836b6e 100644 --- a/functionMap.php +++ b/functionMap.php @@ -32,7 +32,7 @@ 'stripslashes_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], 'urldecode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], 'urlencode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], - 'wp_clear_scheduled_hook' => ['($wp_error is false ? 0|positive-int|false : 0|positive-int|\WP_Error)', 'args'=>$cronArgsType], + 'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args'=>$cronArgsType], 'wp_get_schedule' => [null, 'args'=>$cronArgsType], 'wp_get_scheduled_event' => [null, 'args'=>$cronArgsType], 'WP_Http::get' => [$httpReturnType], diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 63f620a..5db58cb 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -27,6 +27,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/is_wp_error.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/mysql2date.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/term_exists.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_clear_scheduled_hook.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_error_parameter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wp_theme.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/wpdb.php'); diff --git a/tests/data/wp_clear_scheduled_hook.php b/tests/data/wp_clear_scheduled_hook.php new file mode 100644 index 0000000..17a7a77 --- /dev/null +++ b/tests/data/wp_clear_scheduled_hook.php @@ -0,0 +1,12 @@ +|false', wp_clear_scheduled_hook('hook', [])); +assertType('int<0, max>|false', wp_clear_scheduled_hook('hook', [], false)); +assertType('int<0, max>|WP_Error', wp_clear_scheduled_hook('hook', [], true)); From f9a26445b474eca554bc63df94d873298e5f721d Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:58:21 +0100 Subject: [PATCH 04/13] Add wpdb::get_results() to the functions map --- functionMap.php | 3 ++- tests/data/wpdb.php | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/functionMap.php b/functionMap.php index 2836b6e..5d20545 100644 --- a/functionMap.php +++ b/functionMap.php @@ -128,5 +128,6 @@ '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' ? array : \stdClass))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], + 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], + 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \stdClass)))", 'output' => "'OBJECT'|'OBJECT_K'|'ARRAY_A'|'ARRAY_N'"], ]; diff --git a/tests/data/wpdb.php b/tests/data/wpdb.php index cfdfb77..60a697f 100644 --- a/tests/data/wpdb.php +++ b/tests/data/wpdb.php @@ -12,3 +12,10 @@ assertType('stdClass|void|null', wpdb::get_row(null, 'OBJECT')); assertType('array|void|null', wpdb::get_row(null, 'ARRAY_A')); assertType('array|void|null', wpdb::get_row(null, 'ARRAY_N')); + +// wpdb::get_results() +assertType('stdClass|null', wpdb::get_results()); +assertType('stdClass|null', wpdb::get_results(null, 'OBJECT')); +assertType('array|null', wpdb::get_results(null, 'OBJECT_K')); +assertType('array|null', wpdb::get_results(null, 'ARRAY_A')); +assertType('array|null', wpdb::get_results(null, 'ARRAY_N')); From 8c4c4f1866522b950b746d15e4e10035876ed4de Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:16:04 +0100 Subject: [PATCH 05/13] Add get_bookmark() to function map --- functionMap.php | 1 + tests/TypeInferenceTest.php | 1 + tests/data/get_bookmark.php | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/data/get_bookmark.php diff --git a/functionMap.php b/functionMap.php index 5d20545..d10541d 100644 --- a/functionMap.php +++ b/functionMap.php @@ -130,4 +130,5 @@ 'wpdb::prepare' => [null, 'query'=>'literal-string'], 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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'"], ]; diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 5db58cb..07b1623 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -12,6 +12,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/current_time.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/echo_parameter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_attachment_taxonomies.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_bookmark.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_comment.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_object_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_post.php'); diff --git a/tests/data/get_bookmark.php b/tests/data/get_bookmark.php new file mode 100644 index 0000000..6f8e327 --- /dev/null +++ b/tests/data/get_bookmark.php @@ -0,0 +1,16 @@ +|null', get_bookmark($bookmark, 'ARRAY_A')); +assertType('array|null', get_bookmark($bookmark, 'ARRAY_N')); From 91b2e0a8acd5743243cc88d0cf8294341808b2a8 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 21:39:55 +0100 Subject: [PATCH 06/13] Add get_category() to function map --- functionMap.php | 9 +++++---- tests/TypeInferenceTest.php | 1 + tests/data/get_category.php | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tests/data/get_category.php diff --git a/functionMap.php b/functionMap.php index d10541d..e99ab06 100644 --- a/functionMap.php +++ b/functionMap.php @@ -19,7 +19,7 @@ * * '' => [null, ''=>''] * - * @link https://github.com/phpstan/phpstan-src/blob/1.5.x/resources/functionMap.php + * @link https://github.com/phpstan/phpstan-src/blob/1.10.x/resources/functionMap.php */ return [ 'addslashes_gpc' => ['T', '@phpstan-template'=>'T', 'gpc'=>'T'], @@ -128,7 +128,8 @@ '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' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], - 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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'"], + 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], + 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|WP_Error|null) & (\$output is 'ARRAY_A' ? array|WP_Error|null : (\$output is 'ARRAY_N' ? array|WP_Error|null : \WP_Term|WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], ]; diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 07b1623..402147a 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -13,6 +13,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/echo_parameter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_attachment_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_bookmark.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_category.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_comment.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_object_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_post.php'); diff --git a/tests/data/get_category.php b/tests/data/get_category.php new file mode 100644 index 0000000..85862da --- /dev/null +++ b/tests/data/get_category.php @@ -0,0 +1,24 @@ +', get_category($category, 'ARRAY_A')); +assertType('array', get_category($category, 'ARRAY_N')); + +/** @var int|object $category */ +$category; + +assertType('WP_Error|WP_Term|null', get_category($category)); +assertType('WP_Error|WP_Term|null', get_category($category, 'OBJECT')); +assertType('array|WP_Error|null', get_category($category, 'ARRAY_A')); +assertType('array|WP_Error|null', get_category($category, 'ARRAY_N')); From fb06106a9cdc7a2dc7e137a9f87b030b54a98c4d Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 21:59:39 +0100 Subject: [PATCH 07/13] Add argument type to get_term() --- functionMap.php | 2 +- tests/data/get_term.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functionMap.php b/functionMap.php index e99ab06..e1eda8b 100644 --- a/functionMap.php +++ b/functionMap.php @@ -88,7 +88,7 @@ 'get_post' => ["(\$post is \WP_Post ? array|\WP_Post : array|\WP_Post|null) & (\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Post|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'" ], 'get_term_by' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|false : (\$output is 'ARRAY_N' ? list|\WP_Error|false : \WP_Term|\WP_Error|false))"], 'get_page_by_path' => ["(\$output is 'ARRAY_A' ? array|null : (\$output is 'ARRAY_N' ? array|null : \WP_Post|null))"], - 'get_term' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? list|\WP_Error|null : \WP_Term|\WP_Error|null))"], + 'get_term' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? list|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output'=>"'OBJECT'|'ARRAY_A'|'ARRAY_N'"], 'has_action' => ['($callback is false ? bool : false|int)'], 'has_filter' => ['($callback is false ? bool : false|int)'], 'get_permalink' => ['($post is \WP_Post ? string : string|false)'], diff --git a/tests/data/get_term.php b/tests/data/get_term.php index fcb209b..8541267 100644 --- a/tests/data/get_term.php +++ b/tests/data/get_term.php @@ -14,4 +14,4 @@ assertType( 'array|WP_Error|null', get_term( 2, '', ARRAY_A ) ); assertType( 'array|WP_Error|null', get_term( 2, 'category', ARRAY_A ) ); assertType( 'array|WP_Error|null', get_term( 2, '', ARRAY_N ) ); -assertType( 'array|WP_Error|null', get_term( 2, 'category', ARRAY_N ) ); \ No newline at end of file +assertType( 'array|WP_Error|null', get_term( 2, 'category', ARRAY_N ) ); From 0850d29f5e0bc27df97dff03616fd9f6d7271ab2 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:13:56 +0100 Subject: [PATCH 08/13] Use fully qualified name --- functionMap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functionMap.php b/functionMap.php index e1eda8b..b3bd2b5 100644 --- a/functionMap.php +++ b/functionMap.php @@ -131,5 +131,5 @@ 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|WP_Error|null) & (\$output is 'ARRAY_A' ? array|WP_Error|null : (\$output is 'ARRAY_N' ? array|WP_Error|null : \WP_Term|WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], + 'get_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], ]; From f63e181b3d05ef3774f06574085db32c4019c06f Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:24:35 +0100 Subject: [PATCH 09/13] Add get_category_by_path() to function map --- functionMap.php | 1 + tests/TypeInferenceTest.php | 1 + tests/data/get_category_by_path.php | 16 ++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/data/get_category_by_path.php diff --git a/functionMap.php b/functionMap.php index b3bd2b5..5bd0508 100644 --- a/functionMap.php +++ b/functionMap.php @@ -132,4 +132,5 @@ 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], + 'get_category_by_path' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"] ]; diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 402147a..0d6c404 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -14,6 +14,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/get_attachment_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_bookmark.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_category.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_category_by_path.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_comment.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_object_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_post.php'); diff --git a/tests/data/get_category_by_path.php b/tests/data/get_category_by_path.php new file mode 100644 index 0000000..9b07cb7 --- /dev/null +++ b/tests/data/get_category_by_path.php @@ -0,0 +1,16 @@ +|WP_Error|null', get_category_by_path('', $bool, 'ARRAY_A')); +assertType('array|WP_Error|null', get_category_by_path('', $bool, 'ARRAY_N')); From 489dbdc84f3b2fee039825ea80b8f59ced473db6 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:33:02 +0100 Subject: [PATCH 10/13] Remove types already added without function map --- functionMap.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/functionMap.php b/functionMap.php index 5bd0508..353caa2 100644 --- a/functionMap.php +++ b/functionMap.php @@ -43,7 +43,6 @@ 'WP_List_Table::pagination' => ['void', 'which'=>'"top"|"bottom"'], 'WP_List_Table::set_pagination_args' => ['void', 'args'=>'array{total_items?: int, total_pages?: int, per_page?: int}'], 'wp_next_scheduled' => [null, 'args'=>$cronArgsType], - 'WP_Post_Type::__construct' => ['void', 'args'=>'array'], 'WP_Query::have_posts' => [null, '@phpstan-impure'=>''], 'wp_remote_get' => [$httpReturnType], 'wp_remote_head' => [$httpReturnType], @@ -57,7 +56,6 @@ 'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], 'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], 'wp_slash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], - 'WP_Taxonomy::__construct' => ['void', 'args'=>'array'], 'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], 'wp_unslash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], 'wp_widget_rss_form' => ['void', 'args'=>$wpWidgetRssFormArgsType, 'input'=>$wpWidgetRssFormInputType], From f559915056a5969228ef787a0e49aad01e8fe43e Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:33:21 +0100 Subject: [PATCH 11/13] Add spaces around array assignment operator --- functionMap.php | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/functionMap.php b/functionMap.php index 353caa2..c68c033 100644 --- a/functionMap.php +++ b/functionMap.php @@ -13,25 +13,25 @@ /** * This array is in the same format as the function map array in PHPStan: * - * '' => ['', ''=>''] + * '' => ['', '' => ''] * * For classes, or if you don't wish to define the `@phpstan-return` tag: * - * '' => [null, ''=>''] + * '' => [null, '' => ''] * * @link https://github.com/phpstan/phpstan-src/blob/1.10.x/resources/functionMap.php */ return [ - 'addslashes_gpc' => ['T', '@phpstan-template'=>'T', 'gpc'=>'T'], - 'get_objects_in_term' => [null, 'args'=>'array{order?: string}'], - 'have_posts' => [null, '@phpstan-impure'=>''], - 'rawurlencode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], - 'sanitize_category' => ['T', '@phpstan-template'=>'T of array|object', 'category'=>'T'], - 'sanitize_post' => ['T', '@phpstan-template'=>'T of array|object', 'post'=>'T'], - 'sanitize_term' => ['T', '@phpstan-template'=>'T of array|object', 'term'=>'T'], - 'stripslashes_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], - 'urldecode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], - 'urlencode_deep' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], + 'addslashes_gpc' => ['T', '@phpstan-template' => 'T', 'gpc' => 'T'], + 'get_objects_in_term' => [null, 'args' => 'array{order?: string}'], + 'have_posts' => [null, '@phpstan-impure' => ''], + 'rawurlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], + 'sanitize_category' => ['T', '@phpstan-template' => 'T of array|object', 'category' => 'T'], + 'sanitize_post' => ['T', '@phpstan-template' => 'T of array|object', 'post' => 'T'], + 'sanitize_term' => ['T', '@phpstan-template' => 'T of array|object', 'term' => 'T'], + 'stripslashes_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], + 'urldecode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], + 'urlencode_deep' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'wp_clear_scheduled_hook' => ['(0|positive-int|($wp_error is false ? false : \WP_Error))', 'args'=>$cronArgsType], 'wp_get_schedule' => [null, 'args'=>$cronArgsType], 'wp_get_scheduled_event' => [null, 'args'=>$cronArgsType], @@ -39,11 +39,11 @@ 'WP_Http::head' => [$httpReturnType], 'WP_Http::post' => [$httpReturnType], 'WP_Http::request' => [$httpReturnType], - 'WP_List_Table::display_tablenav' => ['void', 'which'=>'"top"|"bottom"'], - 'WP_List_Table::pagination' => ['void', 'which'=>'"top"|"bottom"'], - 'WP_List_Table::set_pagination_args' => ['void', 'args'=>'array{total_items?: int, total_pages?: int, per_page?: int}'], + 'WP_List_Table::display_tablenav' => ['void', 'which' => '"top"|"bottom"'], + 'WP_List_Table::pagination' => ['void', 'which' => '"top"|"bottom"'], + 'WP_List_Table::set_pagination_args' => ['void', 'args' => 'array{total_items?: int, total_pages?: int, per_page?: int}'], 'wp_next_scheduled' => [null, 'args'=>$cronArgsType], - 'WP_Query::have_posts' => [null, '@phpstan-impure'=>''], + 'WP_Query::have_posts' => [null, '@phpstan-impure' => ''], 'wp_remote_get' => [$httpReturnType], 'wp_remote_head' => [$httpReturnType], 'wp_remote_post' => [$httpReturnType], @@ -55,25 +55,25 @@ 'wp_safe_remote_request' => [$httpReturnType], 'wp_schedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], 'wp_schedule_single_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], - 'wp_slash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], + 'wp_slash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'wp_unschedule_event' => ['($wp_error is false ? bool : true|\WP_Error)', 'args'=>$cronArgsType], - 'wp_unslash' => ['T', '@phpstan-template'=>'T', 'value'=>'T'], + 'wp_unslash' => ['T', '@phpstan-template' => 'T', 'value' => 'T'], 'wp_widget_rss_form' => ['void', 'args'=>$wpWidgetRssFormArgsType, 'input'=>$wpWidgetRssFormInputType], - 'WP_REST_Request' => [null, '@phpstan-template'=>'T of array', '@phpstan-implements'=>'ArrayAccess, value-of>'], - 'WP_REST_Request::offsetExists' => [null, 'offset'=>'@param key-of'], - 'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template'=>'TOffset of key-of', 'offset'=>'TOffset'], - 'WP_REST_Request::offsetSet' => ['void', '@phpstan-template'=>'TOffset of key-of', 'offset'=>'TOffset', 'value'=>'T[TOffset]'], - 'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template'=>'TOffset of key-of', 'offset'=>'TOffset'], + 'WP_REST_Request' => [null, '@phpstan-template' => 'T of array', '@phpstan-implements' => 'ArrayAccess, value-of>'], + 'WP_REST_Request::offsetExists' => [null, 'offset' => '@param key-of'], + 'WP_REST_Request::offsetGet' => ['T[TOffset]', '@phpstan-template' => 'TOffset of key-of', 'offset' => 'TOffset'], + 'WP_REST_Request::offsetSet' => ['void', '@phpstan-template' => 'TOffset of key-of', 'offset' => 'TOffset', 'value' => 'T[TOffset]'], + 'WP_REST_Request::offsetUnset' => ['void', '@phpstan-template' => 'TOffset of key-of', 'offset' => 'TOffset'], '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'"], '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)"], 'WP_Theme::offsetExists' => ['($offset is ThemeKey ? true : false)'], 'WP_Theme::offsetGet' => ['($offset is ThemeKey ? mixed : null)'], - 'WP_Block_List' => [null, '@phpstan-implements'=>'ArrayAccess'], - 'WP_Block_List::offsetExists' => [null, 'index'=>'int'], - 'WP_Block_List::offsetGet' => ['WP_Block|null', 'index'=>'int'], - 'WP_Block_List::offsetSet' => ['void', 'index'=>'int|null'], - 'WP_Block_List::offsetUnset' => ['void', 'index'=>'int'], - 'is_wp_error' => ['($thing is \WP_Error ? true : false)', '@phpstan-assert-if-true'=>'\WP_Error $thing'], + 'WP_Block_List' => [null, '@phpstan-implements' => 'ArrayAccess'], + 'WP_Block_List::offsetExists' => [null, 'index' => 'int'], + 'WP_Block_List::offsetGet' => ['WP_Block|null', 'index' => 'int'], + 'WP_Block_List::offsetSet' => ['void', 'index' => 'int|null'], + 'WP_Block_List::offsetUnset' => ['void', 'index' => 'int'], + 'is_wp_error' => ['($thing is \WP_Error ? true : false)', '@phpstan-assert-if-true' => '\WP_Error $thing'], 'current_time' => ["(\$type is 'timestamp'|'U' ? int : string)"], 'mysql2date' => ["(\$format is 'G'|'U' ? int|false : string|false)"], 'get_post_types' => ["(\$output is 'names' ? array : array)"], @@ -125,8 +125,8 @@ 'WP_Filesystem_Base::dirlist' => [$filesystemDirlistReturnType], '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' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y'=>'0|positive-int'], + 'wpdb::prepare' => [null, 'query' => 'literal-string'], + 'wpdb::get_row' => ["null|void|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : \stdClass))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'", 'y' => '0|positive-int'], 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], From ec59da2dc2296de125e2e2abd08e7bf2c70d89fc Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:38:42 +0100 Subject: [PATCH 12/13] Regenerate function map --- wordpress-stubs.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/wordpress-stubs.php b/wordpress-stubs.php index 1d9cf55..f2b0e2c 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -44535,8 +44535,6 @@ final class WP_Post_Type * _builtin?: bool, * _edit_link?: string, * } $args See register_post_type() - * @phpstan-param array $args - * @phpstan-return void */ public function __construct($post_type, $args = array()) { @@ -50056,8 +50054,6 @@ final class WP_Taxonomy * args?: array, * _builtin?: bool, * } $args See register_taxonomy() - * @phpstan-param array $args - * @phpstan-return void */ public function __construct($taxonomy, $object_type, $args = array()) { @@ -58707,6 +58703,9 @@ public function get_var($query = \null, $x = 0, $y = 0) * respectively. Default OBJECT. * @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-return null|void|($output is 'ARRAY_A' ? array : ($output is 'ARRAY_N' ? array : \stdClass)) */ public function get_row($query = \null, $output = \OBJECT, $y = 0) { @@ -58744,6 +58743,8 @@ public function get_col($query = \null, $x = 0) * of each row's first column's value. Duplicate keys are discarded. * Default OBJECT. * @return array|object|null Database query results. + * @phpstan-param 'OBJECT'|'OBJECT_K'|'ARRAY_A'|'ARRAY_N' $output + * @phpstan-return null|($output is 'ARRAY_A' ? array : ($output is 'ARRAY_N' ? array : ($output is 'OBJECT_K' ? array : \stdClass))) */ public function get_results($query = \null, $output = \OBJECT) { @@ -92403,6 +92404,8 @@ function wp_list_bookmarks($args = '') * respectively. Default OBJECT. * @param string $filter Optional. How to sanitize bookmark fields. Default 'raw'. * @return array|object|null Type returned depends on $output value. + * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output + * @phpstan-return null|($output is 'ARRAY_A' ? array : ($output is 'ARRAY_N' ? array : \stdClass)) */ function get_bookmark($bookmark, $output = \OBJECT, $filter = 'raw') { @@ -94032,6 +94035,8 @@ function get_categories($args = '') * @param string $filter Optional. How to sanitize category fields. Default 'raw'. * @return object|array|WP_Error|null Category data in type defined by $output parameter. * WP_Error if $category is empty, null if it does not exist. + * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output + * @phpstan-return ($category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & ($output is 'ARRAY_A' ? array|\WP_Error|null : ($output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null)) */ function get_category($category, $output = \OBJECT, $filter = 'raw') { @@ -94056,6 +94061,8 @@ function get_category($category, $output = \OBJECT, $filter = 'raw') * correspond to a WP_Term object, an associative array, or a numeric array, * respectively. Default OBJECT. * @return WP_Term|array|WP_Error|null Type is based on $output value. + * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output + * @phpstan-return ($output is 'ARRAY_A' ? array|\WP_Error|null : ($output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null)) */ function get_category_by_path($category_path, $full_match = \true, $output = \OBJECT) { @@ -96837,7 +96844,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 ($wp_error is false ? 0|positive-int|false : 0|positive-int|\WP_Error) + * @phpstan-return (0|positive-int|($wp_error is false ? false : \WP_Error)) */ function wp_clear_scheduled_hook($hook, $args = array(), $wp_error = \false) { @@ -130184,6 +130191,7 @@ function get_tax_sql($tax_query, $primary_table, $primary_id_column) * @param string $filter Optional. How to sanitize term fields. Default 'raw'. * @return WP_Term|array|WP_Error|null WP_Term instance (or array) on success, depending on the `$output` value. * WP_Error if `$taxonomy` does not exist. Null for miscellaneous failure. + * @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output * @phpstan-return ($output is 'ARRAY_A' ? array|\WP_Error|null : ($output is 'ARRAY_N' ? list|\WP_Error|null : \WP_Term|\WP_Error|null)) */ function get_term($term, $taxonomy = '', $output = \OBJECT, $filter = 'raw') From 02621e6758da2434f6e3e39e4d93ee540cbf72ce Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 1 Nov 2023 23:45:49 +0100 Subject: [PATCH 13/13] Add trailing comma to last array item --- functionMap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functionMap.php b/functionMap.php index c68c033..3d7c85e 100644 --- a/functionMap.php +++ b/functionMap.php @@ -130,5 +130,5 @@ 'wpdb::get_results' => ["null|(\$output is 'ARRAY_A' ? array : (\$output is 'ARRAY_N' ? array : (\$output is 'OBJECT_K' ? array : \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_category' => ["(\$category is object ? array|\WP_Term : array|\WP_Term|\WP_Error|null) & (\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], - 'get_category_by_path' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"] + 'get_category_by_path' => ["(\$output is 'ARRAY_A' ? array|\WP_Error|null : (\$output is 'ARRAY_N' ? array|\WP_Error|null : \WP_Term|\WP_Error|null))", 'output' => "'OBJECT'|'ARRAY_A'|'ARRAY_N'"], ];