From 619b5ec26cfb0914ad6badd9f9368b3b67503e8c Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sun, 9 Oct 2022 20:00:30 +0200
Subject: [PATCH] Code Modernization: Add `AllowDynamicProperties` attribute to
all (parent) classes.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
To reduce “noise” in the meantime, both in the error logs of WP users moving onto PHP 8.2, in the test run logs of WP itself, in test runs of plugins and themes, as well as to prevent duplicate tickets from being opened for the same issue, this commit adds the `#[AllowDynamicProperties]` attribute to all “parent” classes in WP.
This commit is an update to the prior patch as committed in [54133].
This commit only affects classes in the `src` directory of WordPress core.
* Tests should not get this attribute, but should be fixed to not use dynamic properties instead. Patches for this are already being committed under ticket #56033.
* While a number bundled themes (2014, 2019, 2020, 2021) contain classes, they are not a part of this commit and may be updated separately.
Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].
Follow-up to [53922], [54133].
See #56513, #56034.
---
src/wp-includes/class-wp-theme-json-data.php | 1 +
.../style-engine/class-wp-style-engine-css-declarations.php | 1 +
src/wp-includes/style-engine/class-wp-style-engine-css-rule.php | 1 +
.../style-engine/class-wp-style-engine-css-rules-store.php | 1 +
src/wp-includes/style-engine/class-wp-style-engine-processor.php | 1 +
src/wp-includes/style-engine/class-wp-style-engine.php | 1 +
6 files changed, 6 insertions(+)
diff --git a/src/wp-includes/class-wp-theme-json-data.php b/src/wp-includes/class-wp-theme-json-data.php
index 089e65eddb..9ffa2f3585 100644
a
|
b
|
|
10 | 10 | /** |
11 | 11 | * Class to provide access to update a theme.json structure. |
12 | 12 | */ |
| 13 | #[AllowDynamicProperties] |
13 | 14 | class WP_Theme_JSON_Data { |
14 | 15 | |
15 | 16 | /** |
diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php b/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php
index 0b9eb59a15..23efd6a40c 100644
a
|
b
|
|
16 | 16 | * |
17 | 17 | * @since 6.1.0 |
18 | 18 | */ |
| 19 | #[AllowDynamicProperties] |
19 | 20 | class WP_Style_Engine_CSS_Declarations { |
20 | 21 | |
21 | 22 | /** |
diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php b/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php
index 6e53418121..53225d7d65 100644
a
|
b
|
|
16 | 16 | * |
17 | 17 | * @since 6.1.0 |
18 | 18 | */ |
| 19 | #[AllowDynamicProperties] |
19 | 20 | class WP_Style_Engine_CSS_Rule { |
20 | 21 | |
21 | 22 | /** |
diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php b/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
index 9b1ed7e706..235fe53e92 100644
a
|
b
|
|
16 | 16 | * |
17 | 17 | * @since 6.1.0 |
18 | 18 | */ |
| 19 | #[AllowDynamicProperties] |
19 | 20 | class WP_Style_Engine_CSS_Rules_Store { |
20 | 21 | |
21 | 22 | /** |
diff --git a/src/wp-includes/style-engine/class-wp-style-engine-processor.php b/src/wp-includes/style-engine/class-wp-style-engine-processor.php
index 8e035b59ee..241437b204 100644
a
|
b
|
|
16 | 16 | * |
17 | 17 | * @since 6.1.0 |
18 | 18 | */ |
| 19 | #[AllowDynamicProperties] |
19 | 20 | class WP_Style_Engine_Processor { |
20 | 21 | |
21 | 22 | /** |
diff --git a/src/wp-includes/style-engine/class-wp-style-engine.php b/src/wp-includes/style-engine/class-wp-style-engine.php
index c6554c5dd9..951dac4b54 100644
a
|
b
|
|
21 | 21 | * @access private |
22 | 22 | * @since 6.1.0 |
23 | 23 | */ |
| 24 | #[AllowDynamicProperties] |
24 | 25 | final class WP_Style_Engine { |
25 | 26 | /** |
26 | 27 | * Style definitions that contain the instructions to |