Commit be6aa372f0 for wordpress.org
commit be6aa372f0d9e297c46294e07bbc7c8a41b605c8
Author: westonruter <westonruter@git.wordpress.org>
Date: Wed Nov 25 19:57:01 2026 +0000
Code Quality: Correct the type of `WP_Theme::$update`.
The property was documented as a boolean when it was declared on the class in r33957, which only accounted for `WP_MS_Themes_List_Table` setting it to true. Since r12066, however, `get_theme_updates()` has stored the theme's entry from the `update_themes` site transient in it, and callers read `new_version` from that array, which PHPStan reported as an offset access on a boolean. The docblock now describes the default, the flag, and the update data, and its type includes the array. This empties the `offsetAccess.nonOffsetAccessible` baseline, so it is removed.
For static analysis the update data is given an open array shape in which `new_version` is always a string, so the values passed to `printf()` and `sprintf()` are no longer mixed at level 10. The contents of the transient are still not validated by `get_theme_updates()`, which is left for a follow-up.
Developed in https://github.com/WordPress/wordpress-develop/pull/16240.
Follow-up to r12066, r33957, r63022.
Props mukesh27, westonruter.
See #66739.
Built from https://develop.svn.wordpress.org/trunk@65791
git-svn-id: http://core.svn.wordpress.org/trunk@64820 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php
index 47ec3db919..d6f0fa8d7d 100644
--- a/wp-includes/class-wp-theme.php
+++ b/wp-includes/class-wp-theme.php
@@ -27,12 +27,30 @@
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.
+ *
+ * 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
+ * @var bool|array<string, mixed>
+ * @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()
*/
public $update = false;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 28ca2c1c86..137bb57bde 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.3-alpha-65790';
+$wp_version = '7.3-alpha-65791';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.