From b061fdccdc2e30a47167fb99131e06b715eea13f Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 2 Nov 2026 19:34:46 -0800 Subject: [PATCH] Document theme JSON resolver cached properties as nullable The static caches `$core`, `$blocks`, `$theme`, `$user`, `$user_custom_post_type_id`, and `$i18n_schema` on `WP_Theme_JSON_Resolver` all default to `null` and are reset to `null` in `clean_cached_data()`, but their `@var` tags left out `null`. Add it, and drop the six resulting `assign.propertyType` entries from the PHPStan baseline. This mirrors the same fix to `WP_Theme_JSON_Resolver_Gutenberg` in Gutenberg. Co-Authored-By: Claude Opus 5.5 (high effort) Claude-Code-Session-Id: e6cf5d9d-7b29-4126-899f-5239ba40d63b --- .../class-wp-theme-json-resolver.php | 12 ++++---- .../baselines/assign.propertyType.neon | 30 ------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index c8129e1ebc864..42a64809d82f5 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -47,7 +47,7 @@ class WP_Theme_JSON_Resolver { * Container for data coming from core. * * @since 5.8.0 - * @var WP_Theme_JSON + * @var WP_Theme_JSON|null */ protected static $core = null; @@ -55,7 +55,7 @@ class WP_Theme_JSON_Resolver { * Container for data coming from the blocks. * * @since 6.1.0 - * @var WP_Theme_JSON + * @var WP_Theme_JSON|null */ protected static $blocks = null; @@ -63,7 +63,7 @@ class WP_Theme_JSON_Resolver { * Container for data coming from the theme. * * @since 5.8.0 - * @var WP_Theme_JSON + * @var WP_Theme_JSON|null */ protected static $theme = null; @@ -71,7 +71,7 @@ class WP_Theme_JSON_Resolver { * Container for data coming from the user. * * @since 5.9.0 - * @var WP_Theme_JSON + * @var WP_Theme_JSON|null */ protected static $user = null; @@ -80,7 +80,7 @@ class WP_Theme_JSON_Resolver { * that holds the user data. * * @since 5.9.0 - * @var int + * @var int|null */ protected static $user_custom_post_type_id = null; @@ -89,7 +89,7 @@ class WP_Theme_JSON_Resolver { * * @since 5.8.0 As `$theme_json_i18n`. * @since 5.9.0 Renamed from `$theme_json_i18n` to `$i18n_schema`. - * @var array + * @var array|null */ protected static $i18n_schema = null; diff --git a/tests/phpstan/baselines/assign.propertyType.neon b/tests/phpstan/baselines/assign.propertyType.neon index 9d852663a7340..a4ea6afb84d31 100644 --- a/tests/phpstan/baselines/assign.propertyType.neon +++ b/tests/phpstan/baselines/assign.propertyType.neon @@ -53,36 +53,6 @@ parameters: identifier: assign.propertyType count: 1 path: ../../../src/wp-includes/class-wp-term-query.php - - - message: '#^Static property WP_Theme_JSON_Resolver\:\:\$blocks \(WP_Theme_JSON\) does not accept null\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../src/wp-includes/class-wp-theme-json-resolver.php - - - message: '#^Static property WP_Theme_JSON_Resolver\:\:\$core \(WP_Theme_JSON\) does not accept null\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../src/wp-includes/class-wp-theme-json-resolver.php - - - message: '#^Static property WP_Theme_JSON_Resolver\:\:\$i18n_schema \(array\) does not accept null\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../src/wp-includes/class-wp-theme-json-resolver.php - - - message: '#^Static property WP_Theme_JSON_Resolver\:\:\$theme \(WP_Theme_JSON\) does not accept null\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../src/wp-includes/class-wp-theme-json-resolver.php - - - message: '#^Static property WP_Theme_JSON_Resolver\:\:\$user \(WP_Theme_JSON\) does not accept null\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../src/wp-includes/class-wp-theme-json-resolver.php - - - message: '#^Static property WP_Theme_JSON_Resolver\:\:\$user_custom_post_type_id \(int\) does not accept null\.$#' - identifier: assign.propertyType - count: 1 - path: ../../../src/wp-includes/class-wp-theme-json-resolver.php - message: '#^Property WP_User\:\:\$roles \(array\\) does not accept array\\.$#' identifier: assign.propertyType