From 84467812c8dda8ce32fa665beb5a5933e61d9a48 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 21 Dec 2021 00:26:44 +0000 Subject: [PATCH] Editor: Explicitly declare `$post_types` and `$area` properties in `WP_Block_Template` class. The `$post_types` and `$area` properties are assigned in the `_build_block_template_result_from_file()` and `_build_block_template_result_from_post()` functions. However, neither property was explicitly declared in the `WP_Block_Template` class. This commit explicitly declares both properties in the class. Why? (1) To make the code more readable and maintainable; (2) to avoid a `Deprecated: Creation of dynamic property WP_Block_Template::$post_types is deprecated` deprecation when PHP 8.2 is released. Ref: * PHP 8.2 Deprecate dynamic properties https://wiki.php.net/rfc/deprecate_dynamic_properties Follow-up to [52062]. Props jrf. Fixes #54670. git-svn-id: https://develop.svn.wordpress.org/trunk@52397 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-block-template.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wp-includes/class-wp-block-template.php b/src/wp-includes/class-wp-block-template.php index b331fa1274..51dbdbfbc3 100644 --- a/src/wp-includes/class-wp-block-template.php +++ b/src/wp-includes/class-wp-block-template.php @@ -129,4 +129,20 @@ class WP_Block_Template { * @var int */ public $author; + + /** + * Post types. + * + * @since 5.9.0 + * @var array + */ + public $post_types; + + /** + * Area. + * + * @since 5.9.0 + * @var string + */ + public $area; }