From 196099a419d511fb16d6e900c0a8c7ddab28e09c Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:41:08 +0200 Subject: [PATCH] Fix wp_get_archives (#246) Returns void even if echo is false --- functionMap.php | 2 +- tests/data/wp_get_archives.php | 4 ++-- wordpress-stubs.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/functionMap.php b/functionMap.php index 598ea35..80f7d8b 100644 --- a/functionMap.php +++ b/functionMap.php @@ -59,7 +59,7 @@ 'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'} ? array : string)"], 'wp_get_schedule' => [null, 'args' => $cronArgsType], 'wp_get_scheduled_event' => [null, 'args' => $cronArgsType], - 'wp_get_archives' => ['($args is array{echo: false|0} ? string : void)'], + 'wp_get_archives' => ['($args is array{echo: false|0} ? string|void : void)'], 'WP_Http::get' => [$httpReturnType], 'WP_Http::head' => [$httpReturnType], 'WP_Http::post' => [$httpReturnType], diff --git a/tests/data/wp_get_archives.php b/tests/data/wp_get_archives.php index d647dde..a1c8a18 100644 --- a/tests/data/wp_get_archives.php +++ b/tests/data/wp_get_archives.php @@ -23,8 +23,8 @@ assertType('null', wp_get_archives(['echo' => 1, 'key' => 'value'])); // Explicit value of false|0 -assertType('string', wp_get_archives(['echo' => false, 'key' => 'value'])); -assertType('string', wp_get_archives(['echo' => 0, 'key' => 'value'])); +assertType('string|null', wp_get_archives(['echo' => false, 'key' => 'value'])); +assertType('string|null', wp_get_archives(['echo' => 0, 'key' => 'value'])); // Unknown value assertType('string|null', wp_get_archives(['echo' => Faker::bool(), 'key' => 'value'])); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index ed58178..b320c6c 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -111994,7 +111994,7 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after = * day?: string, * w?: string, * } $args - * @phpstan-return ($args is array{echo: false|0} ? string : void) + * @phpstan-return ($args is array{echo: false|0} ? string|void : void) */ function wp_get_archives($args = '') {