Skip to content

Commit

Permalink
Fix wp_get_archives (#246)
Browse files Browse the repository at this point in the history
Returns void even if echo is false
  • Loading branch information
IanDelMar authored Oct 9, 2024
1 parent 1484a81 commit 196099a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'wp_generate_tag_cloud' => ["(\$args is array{format: 'array'} ? array<int, string> : 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],
Expand Down
4 changes: 2 additions & 2 deletions tests/data/wp_get_archives.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));
Expand Down
2 changes: 1 addition & 1 deletion wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '')
{
Expand Down

0 comments on commit 196099a

Please sign in to comment.