From 7ef2b928c7ae0bf93e1e002d61854681953d1934 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 29 Aug 2026 07:58:19 +0000 Subject: [PATCH] Fix PHPStan errors with WordPress 7.1 stubs `WP_Theme::get()` is now typed as returning `string|false`, so guard the header values before passing them to `html_entity_decode()`/`wordwrap()`. --- src/WP_CLI/ExtensionUpgraderSkin.php | 6 +++++- src/WP_CLI/ParseThemeNameInput.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/WP_CLI/ExtensionUpgraderSkin.php b/src/WP_CLI/ExtensionUpgraderSkin.php index cef43ad2..4a2cd169 100644 --- a/src/WP_CLI/ExtensionUpgraderSkin.php +++ b/src/WP_CLI/ExtensionUpgraderSkin.php @@ -22,7 +22,11 @@ public function before() { if ( isset( $this->plugin_info ) && is_array( $this->plugin_info ) && isset( $this->plugin_info['Name'] ) ) { WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->plugin_info['Name'], ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ); } elseif ( isset( $this->theme_info ) && is_object( $this->theme_info ) && method_exists( $this->theme_info, 'get' ) ) { - WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $this->theme_info->get( 'Name' ), ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ); + $theme_name = $this->theme_info->get( 'Name' ); + + if ( false !== $theme_name ) { + WP_CLI::log( sprintf( 'Updating %s...', html_entity_decode( $theme_name, ENT_QUOTES, get_bloginfo( 'charset' ) ) ) ); + } } } } diff --git a/src/WP_CLI/ParseThemeNameInput.php b/src/WP_CLI/ParseThemeNameInput.php index b0bc1ae6..df46b9c8 100644 --- a/src/WP_CLI/ParseThemeNameInput.php +++ b/src/WP_CLI/ParseThemeNameInput.php @@ -138,6 +138,8 @@ private function get_all_themes() { $theme_type = 'block'; } + $description = $theme->get( 'Description' ); + $items[ $stylesheet ] = [ 'name' => $key, 'status' => $this->get_status( $theme ), @@ -147,7 +149,7 @@ private function get_all_themes() { 'version' => $theme->get( 'Version' ), 'update_id' => $stylesheet, 'title' => $theme->get( 'Name' ), - 'description' => wordwrap( $theme->get( 'Description' ) ), + 'description' => false !== $description ? wordwrap( $description ) : '', 'author' => $theme->get( 'Author' ), 'auto_update' => in_array( $stylesheet, $auto_updates, true ), 'auto_update_indicated' => $auto_update_indicated,