Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/wp-content/themes/twentytwenty/inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ function twentytwenty_site_logo( $args = array(), $display = true ) {
* @since Twenty Twenty 1.0
*
* @param bool $display Display or return the HTML.
* @return string|void The HTML to display.
* @return string|void The HTML when `$display` is false, null when the site has no
* description. Nothing otherwise.
* @phpstan-return ( $display is true ? void : string|null )
*/
function twentytwenty_site_description( $display = true ) {
$description = get_bloginfo( 'description' );

if ( ! $description ) {
return;
return null;
}

$wrapper = '<div class="site-description">%s</div><!-- .site-description -->';
Expand Down
7 changes: 6 additions & 1 deletion src/wp-includes/author-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,12 @@ function get_author_posts_url( $author_id, $author_nicename = '' ) {
* @type int[]|string $exclude Array or comma/space-separated list of author IDs to exclude. Default empty.
* @type int[]|string $include Array or comma/space-separated list of author IDs to include. Default empty.
* }
* @return void|string Void if 'echo' argument is true, list of authors if 'echo' is false.
* @return string|void List of authors if 'echo' is false, nothing otherwise.
* @phpstan-return (
* $args is array{ echo: false|0|''|'0', ... }
* ? string
* : ( $args is ''|array ? void : string|null )
* )
*/
function wp_list_authors( $args = '' ) {
global $wpdb;
Expand Down
7 changes: 6 additions & 1 deletion src/wp-includes/bookmark-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
* $categorize is true. Accepts 'ASC' (ascending) or 'DESC' (descending).
* Default 'ASC'.
* }
* @return void|string Void if 'echo' argument is true, HTML list of bookmarks if 'echo' is false.
* @return string|void HTML list of bookmarks if 'echo' is false, nothing otherwise.
* @phpstan-return (
* $args is array{ echo: false|0|''|'0', ... }
* ? string
* : ( $args is ''|array ? void : string|null )
* )
*/
function wp_list_bookmarks( $args = '' ) {
$defaults = array(
Expand Down
16 changes: 12 additions & 4 deletions src/wp-includes/category-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,16 @@ function wp_list_categories( $args = '' ) {
* associated with the taxonomy.
* @type bool $echo Whether or not to echo the return value. Default true.
* }
* @return void|string|string[] Void if 'echo' argument is true, or on failure. Otherwise, tag cloud
* as a string or an array, depending on 'format' argument.
* @return string|string[]|void Tag cloud as a string, or as an array when the 'format' argument
* is 'array'. Null on failure. Nothing when 'echo' is true and
* 'format' is not 'array'.
* @phpstan-return (
* $args is array{ format: 'array', ... }
* ? string[]|null
* : ( $args is array{ echo: false|0|''|'0', ... }
* ? string|null
* : ( $args is ''|array ? void : string|string[]|null ) )
* )
*/
function wp_tag_cloud( $args = '' ) {
$defaults = array(
Expand Down Expand Up @@ -745,7 +753,7 @@ function wp_tag_cloud( $args = '' ) {
); // Always query top tags.

if ( empty( $tags ) || is_wp_error( $tags ) ) {
return;
return null;
}

foreach ( $tags as $key => $tag ) {
Expand All @@ -756,7 +764,7 @@ function wp_tag_cloud( $args = '' ) {
}

if ( is_wp_error( $link ) ) {
return;
return null;
}

$tags[ $key ]->link = $link;
Expand Down
6 changes: 4 additions & 2 deletions src/wp-includes/class-wp-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ public function print_scripts( $handles = false, $group = false ) {
* @param string $handle The script's registered handle.
* @param bool $display Optional. Whether to print the extra script
* instead of just returning it. Default true.
* @return bool|string|null Null if no data exists, extra scripts if `$display` is true,
* @return bool|string|null Null if no data exists, extra scripts if `$display` is false,
* true otherwise.
* @phpstan-return ( $display is true ? true|null : string|null )
*/
public function print_scripts_l10n( $handle, $display = true ) {
_deprecated_function( __FUNCTION__, '3.3.0', 'WP_Scripts::print_extra_script()' );
Expand All @@ -217,8 +218,9 @@ public function print_scripts_l10n( $handle, $display = true ) {
* @param string $handle The script's registered handle.
* @param bool $display Optional. Whether to print the extra script
* instead of just returning it. Default true.
* @return bool|string|null Null if no data exists, extra scripts if `$display` is true,
* @return bool|string|null Null if no data exists, extra scripts if `$display` is false,
* true otherwise.
* @phpstan-return ( $display is true ? true|null : string|null )
*/
public function print_extra_script( $handle, $display = true ) {
$output = $this->get_data( $handle, 'data' );
Expand Down
3 changes: 2 additions & 1 deletion src/wp-includes/class-wp-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,9 @@ public function add_inline_style( $handle, $code ) {
* @param string $handle The style's registered handle.
* @param bool $display Optional. Whether to print the inline style
* instead of just returning it. Default true.
* @return string|bool False if no data exists, inline styles if `$display` is true,
* @return string|bool False if no data exists, inline styles if `$display` is false,
* true otherwise.
* @phpstan-return ( $display is true ? bool : string|false )
*/
public function print_inline_style( $handle, $display = true ) {
$output = $this->get_data( $handle, 'after' );
Expand Down
32 changes: 21 additions & 11 deletions src/wp-includes/comment-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ function comment_author_url_link( $link_text = '', $before = '', $after = '', $c
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
* @param bool $display Optional. Whether to print or return the output.
* Default true.
* @return void|string Void if `$display` argument is true, comment classes if `$display` is false.
* @return string|void Comment classes if `$display` is false, nothing otherwise.
* @phpstan-return ( $display is true ? void : string )
*/
function comment_class( $css_class = '', $comment = null, $post = null, $display = true ) {
// Separates classes with a single space, collates classes for comment DIV.
Expand Down Expand Up @@ -1239,10 +1240,14 @@ function get_trackback_url() {
* Displays the current post's trackback URL.
*
* @since 0.71
* @since 2.5.0 Deprecated the `$deprecated_echo` argument.
*
* @param bool $deprecated_echo Not used.
* @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
* for the result instead.
* @see get_trackback_url()
*
* @param bool $deprecated_echo Deprecated. Use {@see get_trackback_url()}. Echo the URL or
* return it. Default true.
* @return string|void The trackback URL when `$deprecated_echo` is false, nothing otherwise.
* @phpstan-return ( $deprecated_echo is true ? void : string )
*/
function trackback_url( $deprecated_echo = true ) {
if ( true !== $deprecated_echo ) {
Expand Down Expand Up @@ -2228,8 +2233,13 @@ function _get_comment_reply_id( $post = null ) {
* @type bool $echo Whether to echo the output or return it. Default true.
* }
* @param WP_Comment[] $comments Optional. Array of WP_Comment objects. Default null.
* @return void|string Void if 'echo' argument is true, or no comments to list.
* Otherwise, HTML list of comments.
* @return string|void HTML list of comments when 'echo' is false, null when there are no
* comments to list. Nothing otherwise.
* @phpstan-return (
* $args is array{ echo: false|0|''|'0', ... }
* ? string|null
* : ( $args is ''|array ? void : string|null )
* )
*/
function wp_list_comments( $args = array(), $comments = null ) {
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
Expand Down Expand Up @@ -2274,12 +2284,12 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( null !== $comments ) {
$comments = (array) $comments;
if ( empty( $comments ) ) {
return;
return null;
}
if ( 'all' !== $parsed_args['type'] ) {
$comments_by_type = separate_comments( $comments );
if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) {
return;
return null;
}
$_comments = $comments_by_type[ $parsed_args['type'] ];
} else {
Expand Down Expand Up @@ -2320,7 +2330,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( 'all' !== $parsed_args['type'] ) {
$comments_by_type = separate_comments( $comments );
if ( empty( $comments_by_type[ $parsed_args['type'] ] ) ) {
return;
return null;
}

$_comments = $comments_by_type[ $parsed_args['type'] ];
Expand All @@ -2332,14 +2342,14 @@ function wp_list_comments( $args = array(), $comments = null ) {
// Otherwise, fall back on the comments from `$wp_query->comments`.
} else {
if ( empty( $wp_query->comments ) ) {
return;
return null;
}
if ( 'all' !== $parsed_args['type'] ) {
if ( empty( $wp_query->comments_by_type ) ) {
$wp_query->comments_by_type = separate_comments( $wp_query->comments );
}
if ( empty( $wp_query->comments_by_type[ $parsed_args['type'] ] ) ) {
return;
return null;
}
$_comments = $wp_query->comments_by_type[ $parsed_args['type'] ];
} else {
Expand Down
19 changes: 11 additions & 8 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8737,19 +8737,22 @@ function wp_get_default_update_php_url() {
* @param string $before Markup to output before the annotation. Default `<p class="description">`.
* @param string $after Markup to output after the annotation. Default `</p>`.
* @param bool $display Whether to echo or return the markup. Default `true` for echo.
* @return string|null Update PHP page annotation if available and $display is false, null otherwise.
* @return string|void Update PHP page annotation when `$display` is false, null when no
* annotation is available. Nothing otherwise.
* @phpstan-return ( $display is true ? void : string|null )
*/
function wp_update_php_annotation( $before = '<p class="description">', $after = '</p>', $display = true ) {
$annotation = wp_get_update_php_annotation();

if ( $annotation ) {
if ( $display ) {
echo $before . $annotation . $after;
} else {
return $before . $annotation . $after;
}
if ( ! $annotation ) {
return null;
}
return null;

if ( ! $display ) {
return $before . $annotation . $after;
}

echo $before . $annotation . $after;
}

/**
Expand Down
Loading
Loading