Make WordPress Core

Changeset 52397


Ignore:
Timestamp:
12/21/2021 12:26:44 AM (5 years ago)
Author:
hellofromTonya
Message:

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:

Follow-up to [52062].

Props jrf.
Fixes #54670.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-template.php

    r52357 r52397  
    130130         */
    131131        public $author;
     132
     133        /**
     134         * Post types.
     135         *
     136         * @since 5.9.0
     137         * @var array
     138         */
     139        public $post_types;
     140
     141        /**
     142         * Area.
     143         *
     144         * @since 5.9.0
     145         * @var string
     146         */
     147        public $area;
    132148}
Note: See TracChangeset for help on using the changeset viewer.