diff --git a/functionMap.php b/functionMap.php index 35ed6417..12045d1e 100644 --- a/functionMap.php +++ b/functionMap.php @@ -210,4 +210,6 @@ '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: int<1, max>, url: string, width: int<0, max>, height: int<0, max>}'], + 'get_user' => ['($user_id is int ? false : \WP_User|false)'], + 'get_user_by' => ["(\$field is 'id'|'ID' ? (\$value is int ? false : \WP_User|false) : \WP_User|false)"], ]; diff --git a/tests/TypeInferenceTest.php b/tests/TypeInferenceTest.php index 26ba0900..42067a55 100644 --- a/tests/TypeInferenceTest.php +++ b/tests/TypeInferenceTest.php @@ -38,6 +38,8 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/get_taxonomies.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_term.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/get_taxonomies_for_attachments.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_user.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/get_user_by.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/has_filter.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/is_new_day.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/is_wp_error.php'); diff --git a/tests/data/get_user.php b/tests/data/get_user.php new file mode 100644 index 00000000..7e32d2b4 --- /dev/null +++ b/tests/data/get_user.php @@ -0,0 +1,16 @@ + ? false : \WP_User|false) : \WP_User|false) */ function get_user_by($field, $value) { @@ -141395,6 +141396,7 @@ function delete_user_option($user_id, $option_name, $is_global = \false) * @param int $user_id User ID. * * @return WP_User|false WP_User object on success, false on failure. + * @phpstan-return ($user_id is int ? false : \WP_User|false) */ function get_user($user_id) {