Make WordPress Core


Ignore:
Timestamp:
03/30/2026 06:01:58 AM (6 months ago)
Author:
westonruter
Message:

Code Quality: Replace void with proper return types in Administration PHPDoc annotations.

Replace void in union return types with null or remove it where the function always returns a value or dies, across 8 files in wp-admin/includes. Adds explicit return null; statements where functions previously fell through without a return value.

Additionally:

  • Adds @return never for media_send_to_editor() and removes misleading return from its callers.
  • Removes void from return types where the function always returns a value or exits: write_post(), WP_Importer::set_blog(), WP_Importer::set_user().
  • Replaces mixed|void with a specific array shape for WP_Site_Health::perform_test().

Developed in https://github.com/WordPress/wordpress-develop/pull/11008

Follow-up to r62178, r62177, r61766, r61719.

Props apermo, xate, westonruter, mukesh27, desrosj.
Fixes #64702.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r62040 r62179  
    983983 * @since 2.0.0
    984984 *
    985  * @return int|void Post ID on success, void on failure.
     985 * @return int Post ID on success. Dies on failure.
    986986 */
    987987function write_post() {
     
    989989        if ( is_wp_error( $result ) ) {
    990990                wp_die( $result->get_error_message() );
    991         } else {
    992                 return $result;
    993         }
     991        }
     992
     993        return $result;
    994994}
    995995
Note: See TracChangeset for help on using the changeset viewer.