Skip to content

Commit 50a3cc8

Browse files
committed
Code Quality: Replace void with null in union return types in link-template.php.
Developed in #11004 Follow-up to r61719, r61716, r32598. Props apermo, xate, westonruter, noruzzaman. See #64694, #64238. Fixes #64699. git-svn-id: https://develop.svn.wordpress.org/trunk@61766 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5d90e3b commit 50a3cc8

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

src/wp-includes/link-template.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) {
11311131
* @param string $after Optional. Display after edit link. Default empty.
11321132
* @param int|WP_Term|null $term Optional. Term ID or object. If null, the queried object will be inspected. Default null.
11331133
* @param bool $display Optional. Whether or not to echo the return. Default true.
1134-
* @return string|void HTML content.
1134+
* @return string|null HTML content.
11351135
*/
11361136
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) {
11371137
if ( is_null( $term ) ) {
@@ -1141,12 +1141,12 @@ function edit_term_link( $link = '', $before = '', $after = '', $term = null, $d
11411141
}
11421142

11431143
if ( ! $term ) {
1144-
return;
1144+
return null;
11451145
}
11461146

11471147
$tax = get_taxonomy( $term->taxonomy );
11481148
if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
1149-
return;
1149+
return null;
11501150
}
11511151

11521152
if ( empty( $link ) ) {
@@ -1552,7 +1552,7 @@ function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $cs
15521552
* @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`.
15531553
* @param string $deprecated Not used.
15541554
* @param bool $force_delete Optional. Whether to bypass Trash and force deletion. Default false.
1555-
* @return string|void The delete post link URL for the given post.
1555+
* @return string|null The delete post link URL for the given post.
15561556
*/
15571557
function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) {
15581558
if ( ! empty( $deprecated ) ) {
@@ -1562,17 +1562,17 @@ function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = fals
15621562
$post = get_post( $post );
15631563

15641564
if ( ! $post ) {
1565-
return;
1565+
return null;
15661566
}
15671567

15681568
$post_type_object = get_post_type_object( $post->post_type );
15691569

15701570
if ( ! $post_type_object ) {
1571-
return;
1571+
return null;
15721572
}
15731573

15741574
if ( ! current_user_can( 'delete_post', $post->ID ) ) {
1575-
return;
1575+
return null;
15761576
}
15771577

15781578
$action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
@@ -1600,14 +1600,14 @@ function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = fals
16001600
* @param int|WP_Comment $comment_id Optional. Comment ID or WP_Comment object.
16011601
* @param string $context Optional. Context in which the URL should be used. Either 'display',
16021602
* to include HTML entities, or 'url'. Default 'display'.
1603-
* @return string|void The edit comment link URL for the given comment, or void if the comment id does not exist or
1603+
* @return string|null The edit comment link URL for the given comment, or null if the comment does not exist or
16041604
* the current user is not allowed to edit it.
16051605
*/
16061606
function get_edit_comment_link( $comment_id = 0, $context = 'display' ) {
16071607
$comment = get_comment( $comment_id );
16081608

16091609
if ( ! is_object( $comment ) || ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
1610-
return;
1610+
return null;
16111611
}
16121612

16131613
if ( 'display' === $context ) {
@@ -1674,13 +1674,13 @@ function edit_comment_link( $text = null, $before = '', $after = '' ) {
16741674
* @since 2.7.0
16751675
*
16761676
* @param int|stdClass $link Optional. Bookmark ID. Default is the ID of the current bookmark.
1677-
* @return string|void The edit bookmark link URL.
1677+
* @return string|null The edit bookmark link URL.
16781678
*/
16791679
function get_edit_bookmark_link( $link = 0 ) {
16801680
$link = get_bookmark( $link );
16811681

16821682
if ( ! current_user_can( 'manage_links' ) ) {
1683-
return;
1683+
return null;
16841684
}
16851685

16861686
$location = admin_url( 'link.php?action=edit&link_id=' ) . $link->link_id;
@@ -2057,7 +2057,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
20572057
* @param bool $previous Optional. Whether to display link to previous or next post.
20582058
* Default true.
20592059
* @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
2060-
* @return string|void The adjacent post relational link URL.
2060+
* @return string|null The adjacent post relational link URL.
20612061
*/
20622062
function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
20632063
$post = get_post();
@@ -2068,7 +2068,7 @@ function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $
20682068
}
20692069

20702070
if ( empty( $post ) ) {
2071-
return;
2071+
return null;
20722072
}
20732073

20742074
$post_title = the_title_attribute(
@@ -2515,7 +2515,7 @@ function get_pagenum_link( $pagenum = 1, $escape = true ) {
25152515
* @global int $paged
25162516
*
25172517
* @param int $max_page Optional. Max pages. Default 0.
2518-
* @return string|void The link URL for next posts page.
2518+
* @return string|null The link URL for next posts page.
25192519
*/
25202520
function get_next_posts_page_link( $max_page = 0 ) {
25212521
global $paged;
@@ -2540,7 +2540,7 @@ function get_next_posts_page_link( $max_page = 0 ) {
25402540
*
25412541
* @param int $max_page Optional. Max pages. Default 0.
25422542
* @param bool $display Optional. Whether to echo the link. Default true.
2543-
* @return string|void The link URL for next posts page if `$display = false`.
2543+
* @return string|null The link URL for next posts page if `$display = false`.
25442544
*/
25452545
function next_posts( $max_page = 0, $display = true ) {
25462546
$link = get_next_posts_page_link( $max_page );
@@ -2563,7 +2563,7 @@ function next_posts( $max_page = 0, $display = true ) {
25632563
*
25642564
* @param string $label Content for link text.
25652565
* @param int $max_page Optional. Max pages. Default 0.
2566-
* @return string|void HTML-formatted next posts page link.
2566+
* @return string|null HTML-formatted next posts page link.
25672567
*/
25682568
function get_next_posts_link( $label = null, $max_page = 0 ) {
25692569
global $paged, $wp_query;
@@ -2624,7 +2624,7 @@ function next_posts_link( $label = null, $max_page = 0 ) {
26242624
*
26252625
* @global int $paged
26262626
*
2627-
* @return string|void The link for the previous posts page.
2627+
* @return string|null The link for the previous posts page.
26282628
*/
26292629
function get_previous_posts_page_link() {
26302630
global $paged;
@@ -2646,7 +2646,7 @@ function get_previous_posts_page_link() {
26462646
* @since 0.71
26472647
*
26482648
* @param bool $display Optional. Whether to echo the link. Default true.
2649-
* @return string|void The previous posts page link if `$display = false`.
2649+
* @return string|null The previous posts page link if `$display = false`.
26502650
*/
26512651
function previous_posts( $display = true ) {
26522652
$output = esc_url( get_previous_posts_page_link() );
@@ -2666,7 +2666,7 @@ function previous_posts( $display = true ) {
26662666
* @global int $paged
26672667
*
26682668
* @param string $label Optional. Previous page link text.
2669-
* @return string|void HTML-formatted previous page link.
2669+
* @return string|null HTML-formatted previous page link.
26702670
*/
26712671
function get_previous_posts_link( $label = null ) {
26722672
global $paged;
@@ -3124,13 +3124,13 @@ function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
31243124
* @param string $label Optional. Label for link text. Default empty.
31253125
* @param int $max_page Optional. Max page. Default 0.
31263126
* @param int|null $page Optional. Page number. Default null.
3127-
* @return string|void HTML-formatted link for the next page of comments.
3127+
* @return string|null HTML-formatted link for the next page of comments.
31283128
*/
31293129
function get_next_comments_link( $label = '', $max_page = 0, $page = null ) {
31303130
global $wp_query;
31313131

31323132
if ( ! is_singular() ) {
3133-
return;
3133+
return null;
31343134
}
31353135

31363136
if ( is_null( $page ) ) {
@@ -3152,7 +3152,7 @@ function get_next_comments_link( $label = '', $max_page = 0, $page = null ) {
31523152
}
31533153

31543154
if ( $next_page > $max_page ) {
3155-
return;
3155+
return null;
31563156
}
31573157

31583158
if ( empty( $label ) ) {
@@ -3196,19 +3196,19 @@ function next_comments_link( $label = '', $max_page = 0 ) {
31963196
*
31973197
* @param string $label Optional. Label for comments link text. Default empty.
31983198
* @param int|null $page Optional. Page number. Default null.
3199-
* @return string|void HTML-formatted link for the previous page of comments.
3199+
* @return string|null HTML-formatted link for the previous page of comments.
32003200
*/
32013201
function get_previous_comments_link( $label = '', $page = null ) {
32023202
if ( ! is_singular() ) {
3203-
return;
3203+
return null;
32043204
}
32053205

32063206
if ( is_null( $page ) ) {
32073207
$page = get_query_var( 'cpage' );
32083208
}
32093209

32103210
if ( (int) $page <= 1 ) {
3211-
return;
3211+
return null;
32123212
}
32133213

32143214
$previous_page = (int) $page - 1;

0 commit comments

Comments
 (0)