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
This commit is contained in:
Tonya Mork 2021-12-21 00:26:44 +00:00
parent 3ce5c4c5a8
commit 84467812c8

View File

@ -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;
}