Commit b97ad57e12 for wordpress.org
commit b97ad57e1256e3df819ec0f8ca993169cf515732
Author: westonruter <westonruter@git.wordpress.org>
Date: Wed Nov 25 08:10:54 2026 +0000
Code Quality: Resolve the `deadCode.unreachable` PHPStan errors.
Only one of the unreachable statements in the baseline could never run, the trailing `wp_send_json_error()` in `wp_ajax_set_attachment_thumbnail()`, which would only have appended a second response after one had already been sent, and it is removed. The others are kept on purpose:
* Translatable strings after a `return`, so that they are added to the POT file.
* An `exit` or `break` that keeps a `switch` case from reading as falling through.
* The `wp_die()` fallback for a list table supplied by the `wp_list_table_class_name` filter whose `ajax_response()` returns.
* The `die()` that stops a request with an invalid nonce even if a custom `wp_die()` handler returns.
Since these should never be fixed, they are ignored inline with a reason rather than left in a baseline, which would invite contributors to remove them. Unlike the counted entries used for the HTML API in r64294, an inline ignore names the exact statement, so a genuine unreachable statement added to the same file is still reported. The Ajax handlers involved are also documented as never returning.
Developed in https://github.com/WordPress/wordpress-develop/pull/16224.
Follow-up to r29029, r63023, r64294.
Props mukesh27, westonruter.
See #66739.
Built from https://develop.svn.wordpress.org/trunk@65773
git-svn-id: http://core.svn.wordpress.org/trunk@64802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/about.php b/wp-admin/about.php
index a3c27bca79..a2cf8c5ca1 100644
--- a/wp-admin/about.php
+++ b/wp-admin/about.php
@@ -294,7 +294,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
// These are strings we may use to describe maintenance/security releases, where we aim for no new strings.
return;
-__( 'Maintenance Release' );
+__( 'Maintenance Release' ); // @phpstan-ignore deadCode.unreachable (Placed after the return so that the strings are added to the POT file without running.)
__( 'Maintenance Releases' );
__( 'Security Release' );
diff --git a/wp-admin/credits.php b/wp-admin/credits.php
index 75993cf665..26f06b76a6 100644
--- a/wp-admin/credits.php
+++ b/wp-admin/credits.php
@@ -122,7 +122,7 @@ require_once ABSPATH . 'wp-admin/admin-footer.php';
return;
// These are strings returned by the API that we want to be translatable.
-__( 'Project Leaders' );
+__( 'Project Leaders' ); // @phpstan-ignore deadCode.unreachable (Placed after the return so that the strings are added to the POT file without running.)
/* translators: %s: The current WordPress version number. */
__( 'Core Contributors to WordPress %s' );
__( 'Noteworthy Contributors' );
diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index ba3b9bc285..ede68a275b 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -79,6 +79,8 @@ function wp_ajax_nopriv_heartbeat() {
* Handles fetching a list table via AJAX.
*
* @since 3.1.0
+ *
+ * @return never
*/
function wp_ajax_fetch_list() {
$list_class = $_GET['list_args']['class'];
@@ -95,7 +97,7 @@ function wp_ajax_fetch_list() {
$wp_list_table->ajax_response();
- wp_die( 0 );
+ wp_die( 0 ); // @phpstan-ignore deadCode.unreachable (The wp_list_table_class_name filter can supply a class whose ajax_response() returns.)
}
/**
@@ -2684,6 +2686,8 @@ function wp_ajax_upload_attachment() {
* Handles image editing via AJAX.
*
* @since 3.1.0
+ *
+ * @return never
*/
function wp_ajax_image_editor() {
$attachment_id = (int) $_POST['postid'];
@@ -2705,7 +2709,7 @@ function wp_ajax_image_editor() {
}
wp_send_json_success( $message );
- break;
+ break; // @phpstan-ignore deadCode.unreachable (Ends the case so that it does not read as falling through, which PHPCS reports.)
case 'scale':
$message = wp_save_image( $attachment_id );
break;
@@ -2804,6 +2808,8 @@ function wp_ajax_get_post_thumbnail_html() {
* @since 4.0.0
*
* @see set_post_thumbnail()
+ *
+ * @return never
*/
function wp_ajax_set_attachment_thumbnail() {
if ( empty( $_POST['urls'] ) || ! is_array( $_POST['urls'] ) ) {
@@ -2849,8 +2855,6 @@ function wp_ajax_set_attachment_thumbnail() {
} else {
wp_send_json_success();
}
-
- wp_send_json_error();
}
/**
diff --git a/wp-admin/post.php b/wp-admin/post.php
index 3cb4a9048d..7d685cffe3 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -125,7 +125,7 @@ switch ( $action ) {
check_admin_referer( 'add-' . $post_type );
$post_id = 'postajaxpost' === $action ? edit_post() : write_post();
redirect_post( $post_id );
- exit;
+ exit; // @phpstan-ignore deadCode.unreachable (Ends the case so that it does not read as falling through, which PHPCS reports.)
case 'edit':
$editing = true;
@@ -245,7 +245,7 @@ switch ( $action ) {
redirect_post( $post_id ); // Send user on their way while we keep working.
- exit;
+ exit; // @phpstan-ignore deadCode.unreachable (Ends the case so that it does not read as falling through into the trash case.)
case 'trash':
check_admin_referer( 'trash-post_' . $post_id );
diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
index 0cf3341aba..4262f6e4a0 100644
--- a/wp-includes/capabilities.php
+++ b/wp-includes/capabilities.php
@@ -1365,7 +1365,7 @@ return;
// Dummy gettext calls to get strings in the catalog.
/* translators: User role for administrators. */
-_x( 'Administrator', 'User role' );
+_x( 'Administrator', 'User role' ); // @phpstan-ignore deadCode.unreachable (Placed after the return so that the strings are added to the POT file without running.)
/* translators: User role for editors. */
_x( 'Editor', 'User role' );
/* translators: User role for authors. */
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 94aab93a98..640ab86e06 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -1399,7 +1399,7 @@ if ( ! function_exists( 'check_admin_referer' ) ) :
if ( ! $result && ! ( -1 === $action && str_starts_with( $referer, $adminurl ) ) ) {
wp_nonce_ays( $action );
- die();
+ die(); // @phpstan-ignore deadCode.unreachable (Stops a request with an invalid nonce even if a custom wp_die() handler returns.)
}
return $result;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index fa3ceaf0db..b731baadea 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.3-alpha-65772';
+$wp_version = '7.3-alpha-65773';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.