From 2e2b7b6331b56c0c12d7c3d40b5af1b5e7ea6bfd Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Wed, 25 Nov 2026 16:47:18 +0530 Subject: [PATCH 1/2] Code Quality: Correct the type of `WP_Theme::$update`. `get_theme_updates()` stores the theme's update data array in `WP_Theme::$update`, but the property was documented as `bool`. PHPStan therefore reported every read of `->update['new_version']` as `offsetAccess.nonOffsetAccessible`. Document the property as `bool|array`, which covers both the `true` set by `WP_MS_Themes_List_Table` and the array set by `get_theme_updates()`. This resolves all five errors and removes the `offsetAccess.nonOffsetAccessible` baseline. See #66739. Co-Authored-By: Claude Opus 5.5 --- src/wp-includes/class-wp-theme.php | 5 +++- .../offsetAccess.nonOffsetAccessible.neon | 30 ------------------- 2 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index 47ec3db9194d5..954b8bc241fd0 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -29,10 +29,13 @@ final class WP_Theme implements ArrayAccess { /** * Whether the theme has been marked as updateable. * + * get_theme_updates() sets this to the theme's update data instead. + * * @since 4.4.0 - * @var bool + * @var bool|array * * @see WP_MS_Themes_List_Table + * @see get_theme_updates() */ public $update = false; diff --git a/tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon b/tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon deleted file mode 100644 index ed021ec794760..0000000000000 --- a/tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon +++ /dev/null @@ -1,30 +0,0 @@ -# PHPStan baseline for the `offsetAccess.nonOffsetAccessible` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/offsetAccess.nonOffsetAccessible -# -# Each entry is scoped to a single file and carries an exact occurrence count, -# so that a new instance is reported as a new error rather than being absorbed -# silently. Fixing an occurrence therefore means decrementing or removing its -# entry here as part of the same change. -# -# The goal is to empty this file and delete it. -# -# Generated by `composer phpstan:baselines`. Do not edit by hand. Regenerate with: -# -# composer phpstan:baselines -- --identifier=offsetAccess.nonOffsetAccessible --config=phpstan.neon.dist -# -# This reruns the analysis with the baselines in this directory suppressed, so -# that their errors surface again, and rewrites only this file. - -parameters: - ignoreErrors: - - - message: '#^Cannot access offset ''new_version'' on bool\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 4 - path: ../../../src/wp-admin/includes/class-wp-debug-data.php - - - message: '#^Cannot access offset ''new_version'' on bool\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: ../../../src/wp-admin/update-core.php From bfb77e5006a7dac4201c8af3205c3553e6a8ce04 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 25 Nov 2026 11:19:16 -0800 Subject: [PATCH 2/2] Themes: Document the values of WP_Theme::$update. Describe the three states the property can hold: false by default, true when WP_MS_Themes_List_Table marks the theme as updatable, and the theme's entry from the update_themes site transient when set by get_theme_updates(). Add a `@phpstan-var` array shape for that entry, so that `new_version` is known to be a string rather than mixed. This resolves the level-10 `argument.type` errors where it is passed to printf() and sprintf() in update-core.php and WP_Debug_Data. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 8b5b7697-1a6d-4766-9824-3c2bf5b102d6 --- src/wp-includes/class-wp-theme.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index 954b8bc241fd0..d6f0fa8d7d1a3 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -27,12 +27,27 @@ final class WP_Theme implements ArrayAccess { /** - * Whether the theme has been marked as updateable. + * Whether the theme has been marked as updateable, or the theme's update data. * - * get_theme_updates() sets this to the theme's update data instead. + * This is false by default. WP_MS_Themes_List_Table sets it to true when an + * update is available for the theme, while get_theme_updates() sets it to the + * theme's entry in the `response` of the `update_themes` site transient. That + * entry always contains the `new_version`, and usually the `theme`, `url`, + * `package`, `requires`, and `requires_php` as well, where `requires` and + * `requires_php` are false when the theme does not declare them. Themes updated + * via the {@see 'update_themes_$hostname'} filter may also include other keys. * * @since 4.4.0 * @var bool|array + * @phpstan-var bool|array{ + * new_version: string, + * theme?: string, + * url?: string, + * package?: string, + * requires?: string|false, + * requires_php?: string|false, + * ... + * } * * @see WP_MS_Themes_List_Table * @see get_theme_updates()