From ba5a28932822c70970b9bd298fd560101709bc09 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sun, 9 Oct 2022 20:00:16 +0200
Subject: [PATCH] Code Modernization: Add `AllowDynamicProperties` attribute to
all (parent) classes in themes.
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] and specifically addresses the WP native themes.
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.
Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].
Follow-up to [53922], [54133].
See #56513, #56034.
---
src/wp-content/themes/twentyfourteen/inc/featured-content.php | 1 +
.../twentynineteen/classes/class-twentynineteen-svg-icons.php | 1 +
.../themes/twentytwenty/classes/class-twentytwenty-customize.php | 1 +
.../classes/class-twentytwenty-non-latin-languages.php | 1 +
.../twentytwenty/classes/class-twentytwenty-script-loader.php | 1 +
.../themes/twentytwenty/classes/class-twentytwenty-svg-icons.php | 1 +
.../classes/class-twenty-twenty-one-custom-colors.php | 1 +
.../classes/class-twenty-twenty-one-customize.php | 1 +
.../classes/class-twenty-twenty-one-dark-mode.php | 1 +
.../classes/class-twenty-twenty-one-svg-icons.php | 1 +
10 files changed, 10 insertions(+)
diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php
index da8b76f715..5b35a4bad1 100644
a
|
b
|
|
10 | 10 | * this tag now has special meaning beyond that of a normal tags, users |
11 | 11 | * will have the ability to hide it from the front end of their site. |
12 | 12 | */ |
| 13 | #[AllowDynamicProperties] |
13 | 14 | class Featured_Content { |
14 | 15 | |
15 | 16 | /** |
diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php
index aa2ebf27bb..2d38ee901f 100644
a
|
b
|
|
19 | 19 | * |
20 | 20 | * @since Twenty Nineteen 1.0 |
21 | 21 | */ |
| 22 | #[AllowDynamicProperties] |
22 | 23 | class TwentyNineteen_SVG_Icons { |
23 | 24 | |
24 | 25 | /** |
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
index d4b21ece58..265b2852f8 100644
a
|
b
|
if ( ! class_exists( 'TwentyTwenty_Customize' ) ) { |
13 | 13 | * |
14 | 14 | * @since Twenty Twenty 1.0 |
15 | 15 | */ |
| 16 | #[AllowDynamicProperties] |
16 | 17 | class TwentyTwenty_Customize { |
17 | 18 | |
18 | 19 | /** |
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php
index e5a7f0dc74..a934319ae1 100644
a
|
b
|
if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) { |
15 | 15 | * |
16 | 16 | * @since Twenty Twenty 1.0 |
17 | 17 | */ |
| 18 | #[AllowDynamicProperties] |
18 | 19 | class TwentyTwenty_Non_Latin_Languages { |
19 | 20 | |
20 | 21 | /** |
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php
index 0327420471..e5b36fc567 100644
a
|
b
|
if ( ! class_exists( 'TwentyTwenty_Script_Loader' ) ) { |
17 | 17 | * |
18 | 18 | * @since Twenty Twenty 1.0 |
19 | 19 | */ |
| 20 | #[AllowDynamicProperties] |
20 | 21 | class TwentyTwenty_Script_Loader { |
21 | 22 | |
22 | 23 | /** |
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php
index 714b3a1454..6ead5a43de 100644
a
|
b
|
if ( ! class_exists( 'TwentyTwenty_SVG_Icons' ) ) { |
14 | 14 | * |
15 | 15 | * @since Twenty Twenty 1.0 |
16 | 16 | */ |
| 17 | #[AllowDynamicProperties] |
17 | 18 | class TwentyTwenty_SVG_Icons { |
18 | 19 | /** |
19 | 20 | * GET SVG CODE |
diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-custom-colors.php
index 3b6833c388..3ccba339ac 100644
a
|
b
|
|
10 | 10 | /** |
11 | 11 | * This class is in charge of color customization via the Customizer. |
12 | 12 | */ |
| 13 | #[AllowDynamicProperties] |
13 | 14 | class Twenty_Twenty_One_Custom_Colors { |
14 | 15 | |
15 | 16 | /** |
diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-customize.php
index 4a0fe6f7af..3de3f36d29 100644
a
|
b
|
if ( ! class_exists( 'Twenty_Twenty_One_Customize' ) ) { |
13 | 13 | * |
14 | 14 | * @since Twenty Twenty-One 1.0 |
15 | 15 | */ |
| 16 | #[AllowDynamicProperties] |
16 | 17 | class Twenty_Twenty_One_Customize { |
17 | 18 | |
18 | 19 | /** |
diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php
index 6955fc7c1b..4bdf9abca4 100644
a
|
b
|
|
10 | 10 | /** |
11 | 11 | * This class is in charge of Dark Mode. |
12 | 12 | */ |
| 13 | #[AllowDynamicProperties] |
13 | 14 | class Twenty_Twenty_One_Dark_Mode { |
14 | 15 | |
15 | 16 | /** |
diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-svg-icons.php
index 3a82cf76ab..a601b75a34 100644
a
|
b
|
|
19 | 19 | * |
20 | 20 | * @since Twenty Twenty-One 1.0 |
21 | 21 | */ |
| 22 | #[AllowDynamicProperties] |
22 | 23 | class Twenty_Twenty_One_SVG_Icons { |
23 | 24 | |
24 | 25 | /** |