From f132601ed3b32a2786fd094d80e4b97fb6787f9f Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Mon, 23 Feb 2026 10:52:48 +0100 Subject: [PATCH 1/7] Docs: Replace void with null in union return types in class-wpdb.php Fixes #64703. See #64694. Co-Authored-By: xateman --- src/wp-includes/class-wpdb.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 23c865b87d817..810840208ef05 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -1453,11 +1453,11 @@ private function _escape_identifier_value( $identifier ) { * individual arguments. * @param mixed ...$args Further variables to substitute into the query's placeholders * if being called with individual arguments. - * @return string|void Sanitized query string, if there is a query to prepare. + * @return string|null Sanitized query string, if there is a query to prepare. */ public function prepare( $query, ...$args ) { if ( is_null( $query ) ) { - return; + return null; } /* @@ -2117,7 +2117,7 @@ public function parse_db_host( $host ) { * @since 3.9.0 * * @param bool $allow_bail Optional. Allows the function to bail. Default true. - * @return bool|void True if the connection is up. + * @return bool True if the connection is up. */ public function check_connection( $allow_bail = true ) { // Check if the connection is alive. @@ -3056,7 +3056,7 @@ public function get_var( $query = null, $x = 0, $y = 0 ) { * correspond to an stdClass object, an associative array, or a numeric array, * respectively. Default OBJECT. * @param int $y Optional. Row to return. Indexed from 0. Default 0. - * @return array|object|null|void Database query result in format specified by $output or null on failure. + * @return array|object|null Database query result in format specified by $output or null on failure. */ public function get_row( $query = null, $output = OBJECT, $y = 0 ) { $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; From 80da52a730b7ced03e5cba724b0d3642dc154b10 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Mon, 23 Feb 2026 11:17:58 +0100 Subject: [PATCH 2/7] Update src/wp-includes/class-wpdb.php Co-authored-by: Mukesh Panchal --- src/wp-includes/class-wpdb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 810840208ef05..46c30bdf222d4 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -2117,7 +2117,7 @@ public function parse_db_host( $host ) { * @since 3.9.0 * * @param bool $allow_bail Optional. Allows the function to bail. Default true. - * @return bool True if the connection is up. + * @return bool True if the connection is up, false otherwise. */ public function check_connection( $allow_bail = true ) { // Check if the connection is alive. From 254b43996c69ea50e0b5d1b78438e40cc4311b5d Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Tue, 24 Feb 2026 09:18:58 +0100 Subject: [PATCH 3/7] Docs: Add `@return never` to `dead_db()`. --- src/wp-includes/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 4b6330a697780..e4b96c6418c63 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5501,6 +5501,8 @@ function wp_ob_end_flush_all() { * @since 2.3.2 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @return never */ function dead_db() { global $wpdb; From 0b5d819321090707daf55683dc994773cd8dcb1d Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Tue, 24 Feb 2026 10:42:28 +0100 Subject: [PATCH 4/7] fix(phpstan): Ignore return.never on dead_db() PHPStan cannot verify that wp_die() always terminates due to its conditional return type and treatPhpDocTypesAsCertain being disabled. --- src/wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index e4b96c6418c63..101585166bd65 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5521,7 +5521,7 @@ function dead_db() { } // Otherwise, be terse. - wp_die( '

' . __( 'Error establishing a database connection' ) . '

', __( 'Database Error' ) ); + wp_die( '

' . __( 'Error establishing a database connection' ) . '

', __( 'Database Error' ) ); // @phpstan-ignore return.never (wp_die() always exits by default.) } /** From 8cf94431c3eec4d3cb9626f09e8e90cca8a0d407 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 24 Feb 2026 15:18:55 -0800 Subject: [PATCH 5/7] Fix phpstan-return syntax Co-authored-by: Christoph Daum --- src/wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 101585166bd65..afc421079772a 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3766,7 +3766,7 @@ function wp_nonce_ays( $action ) { * } * @return never|void Returns void if `$args['exit']` is false, otherwise exits. * - * @phpstan-return ( $args['exit'] is false ? void : never ) + * @phpstan-return ( $args is array{exit: false} ? void : never ) */ function wp_die( $message = '', $title = '', $args = array() ) { global $wp_query; From 7b4fbe7a33d954165630127691a942ba9a1c1102 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 24 Feb 2026 15:19:03 -0800 Subject: [PATCH 6/7] Remove now-unnecessary phpstan-ignore --- src/wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index afc421079772a..8bf46ef0b871f 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5521,7 +5521,7 @@ function dead_db() { } // Otherwise, be terse. - wp_die( '

' . __( 'Error establishing a database connection' ) . '

', __( 'Database Error' ) ); // @phpstan-ignore return.never (wp_die() always exits by default.) + wp_die( '

' . __( 'Error establishing a database connection' ) . '

', __( 'Database Error' ) ); } /** From fffe2f6b8700af8cba2dc03e013a04b0399e4b9e Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Wed, 25 Feb 2026 08:14:38 +0100 Subject: [PATCH 7/7] docs: Refine phpdoc of dead_db() Co-authored-by: Weston Ruter --- src/wp-includes/class-wpdb.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 46c30bdf222d4..8168e0b5c515c 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -2117,7 +2117,9 @@ public function parse_db_host( $host ) { * @since 3.9.0 * * @param bool $allow_bail Optional. Allows the function to bail. Default true. - * @return bool True if the connection is up, false otherwise. + * @return bool|never Whether the connection is up. + * + * @phpstan-return ( $allow_bail is true ? bool|never : bool ) */ public function check_connection( $allow_bail = true ) { // Check if the connection is alive.