WordPress/wp-admin
Sergey Biryukov c03305852e Code Modernization: Add `AllowDynamicProperties` attribute to all (parent) classes.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.

Trac ticket #56034 is open to investigate and handle the third and fourth type of situations, however it has become clear this will need more time and will not be ready in time for WP 6.1.

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.

The logic used for this commit is as follows:
* If a class already has the attribute: no action needed.
* If a class does not `extend`: add the attribute.
* If a class does `extend`:
 - If it extends `stdClass`: no action needed (as `stdClass` supports dynamic properties).
 - If it extends a PHP native class: add the attribute.
 - If it extends a class from one of WP's external dependencies: add the attribute.
* In all other cases: no action — the attribute should not be needed as child classes inherit from the parent.

Whether or not a class contains magic methods has not been taken into account, as a review of the currently existing magic methods has shown that those are generally not sturdy enough and often even set dynamic properties (which they should not). See the [https://www.youtube.com/watch?v=vDZWepDQQVE live stream from August 16, 2022] for more details.

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].

Props jrf, hellofromTonya, markjaquith, peterwilsoncc, costdev, knutsp, aristath.
See #56513, #56034.
Built from https://develop.svn.wordpress.org/trunk@54133


git-svn-id: http://core.svn.wordpress.org/trunk@53692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-12 15:47:14 +00:00
..
css Media: Prevent URLs from overflowing their container in the media editor. 2022-07-25 18:11:08 +00:00
images Administration: Update design of the Dashboard welcome panel. 2022-05-10 16:45:08 +00:00
includes Code Modernization: Add `AllowDynamicProperties` attribute to all (parent) classes. 2022-09-12 15:47:14 +00:00
js Site Health: Fix TypeError when copying debug information. 2022-09-06 22:06:19 +00:00
maint
network Coding Standards: Use a consistent markup for line break tags across Core. 2022-09-02 06:51:13 +00:00
user
about.php Help/About: Improve vertical alignment in the Additional Design Tools section. 2022-08-23 13:48:10 +00:00
admin-ajax.php Coding Standards: Remove extra space in `wp-admin/admin-ajax.php`. 2022-05-07 16:21:18 +00:00
admin-footer.php
admin-functions.php
admin-header.php Docs: Add missing description for `$typenow` global in various functions. 2022-04-04 18:39:01 +00:00
admin-post.php Administration: Require a valid action parameter to be set for `admin-ajax.php` requests. 2022-03-02 15:00:11 +00:00
admin.php Docs: Add missing description for `$taxnow` global in various functions. 2022-04-04 18:43:02 +00:00
async-upload.php Media: Remove target blank attribute from media uploader edit links. 2022-01-27 22:17:00 +00:00
authorize-application.php Docs: Various corrections and improvements to inline documentation. 2022-08-04 14:52:11 +00:00
comment.php Administration: Replace contracted verb forms for better consistency. 2022-03-22 16:25:03 +00:00
credits.php Help/About: WordPress 5.9 About Page. 2022-01-04 18:35:03 +00:00
custom-background.php
custom-header.php
customize.php Customizer: When a block theme is active, add an information about Site Editor in the Customizer. 2022-03-29 19:10:14 +00:00
edit-comments.php Coding Standards: Use a consistent markup for line break tags across Core. 2022-09-02 06:51:13 +00:00
edit-form-advanced.php Administration: Remove self-reference ("we") in WordPress Admin. 2022-04-11 11:42:04 +00:00
edit-form-blocks.php Block Editor: Preload settings and templates permissions. 2022-09-06 16:18:11 +00:00
edit-form-comment.php Docs: Explicitly declare some globals for clarity. 2022-05-29 15:35:11 +00:00
edit-link-form.php Administration: Replace contracted verb forms for better consistency. 2022-03-22 16:25:03 +00:00
edit-tag-form.php Taxonomy: Associate field descriptions with fields. 2022-08-19 23:06:09 +00:00
edit-tags.php Taxonomy: Associate field descriptions with fields. 2022-08-19 23:06:09 +00:00
edit.php Docs: Explicitly declare some globals for clarity. 2022-05-29 15:35:11 +00:00
erase-personal-data.php Help/about: Improve text in help tabs of the Personal Data Exporter/Eraser. 2022-04-14 14:46:07 +00:00
export-personal-data.php Help/about: Improve text in help tabs of the Personal Data Exporter/Eraser. 2022-04-14 14:46:07 +00:00
export.php Administration: Remove self-reference ("we") in WordPress Admin. 2022-04-11 11:42:04 +00:00
freedoms.php Administration: Remove self-reference ("we") in WordPress Admin. 2022-04-11 11:42:04 +00:00
import.php
index.php
install-helper.php Code Modernization: Rename parameters that use reserved keywords in `wp-admin/install-helper.php`. 2022-04-20 11:19:12 +00:00
install.php Docs: Use third-person singular verbs for various function descriptions, as per docblocks standards. 2022-09-02 06:58:09 +00:00
link-add.php
link-manager.php
link-parse-opml.php
link.php
load-scripts.php Docs: Update a comment in `wp-admin/load-styles.php` per the documentation standards. 2021-12-12 14:52:02 +00:00
load-styles.php Docs: Update a comment in `wp-admin/load-styles.php` per the documentation standards. 2021-12-12 14:52:02 +00:00
media-new.php
media-upload.php
media.php Administration: Replace contracted verb forms for better consistency. 2022-03-22 16:25:03 +00:00
menu-header.php Administration: Restore the correct escaping function for base64-encoded SVG icons in the admin menu. 2022-04-07 12:54:03 +00:00
menu.php Administration: Make sure the `$customize_url` variable is always defined in the admin menu. 2021-12-25 03:32:03 +00:00
moderation.php
ms-admin.php
ms-delete-site.php
ms-edit.php
ms-options.php
ms-sites.php
ms-themes.php
ms-upgrade-network.php
ms-users.php
my-sites.php
nav-menus.php Text Changes: Improve consistency of punctuation in some strings. 2022-07-14 14:10:11 +00:00
network.php
options-discussion.php Options, Meta APIs: Rephrase the description of the "Avatars" section. 2022-03-28 10:56:04 +00:00
options-general.php Administration: Change default site tagline to an empty string. 2022-08-03 12:20:16 +00:00
options-head.php
options-media.php
options-permalink.php Coding Standards: Clarify time units for various timeout or expiration values. 2022-09-09 08:16:18 +00:00
options-privacy.php Administration: Clarify some sentences after [53131]. 2022-04-12 13:43:16 +00:00
options-reading.php Docs: Use third-person singular verbs for various function descriptions, as per docblocks standards. 2022-09-02 06:58:09 +00:00
options-writing.php
options.php Coding Standards: Clarify time units for various timeout or expiration values. 2022-09-09 08:16:18 +00:00
plugin-editor.php Administration: Correct the escaping in documentation lookup for plugin and theme editor. 2022-07-22 11:33:10 +00:00
plugin-install.php Administration: Replace contracted verb forms for better consistency. 2022-03-22 16:25:03 +00:00
plugins.php Plugins: Escape output in error messages. 2022-08-30 15:18:17 +00:00
post-new.php
post.php Administration: Replace contracted verb forms for better consistency. 2022-03-22 16:25:03 +00:00
press-this.php
privacy-policy-guide.php Administration: Remove self-reference ("we") in WordPress Admin. 2022-04-11 11:42:04 +00:00
privacy.php
profile.php
revision.php Coding Standards: Use strict comparison in `wp-admin/revision.php`. 2022-01-07 16:47:00 +00:00
setup-config.php Database: Suppress errors when checking the validity of table prefix during installation. 2022-08-02 16:34:13 +00:00
site-editor.php Site Editor: Pass correct context into get_block_categories 2022-07-27 12:27:16 +00:00
site-health-info.php
site-health.php Site Health: Don't show issue groups unless there are items in them. 2022-08-28 19:17:11 +00:00
term.php General: Replace all `esc_url_raw()` calls in core with `sanitize_url()`. 2022-06-01 18:14:10 +00:00
theme-editor.php Administration: Correct the escaping in documentation lookup for plugin and theme editor. 2022-07-22 11:33:10 +00:00
theme-install.php Themes: Include a hyphen in the Block Themes tab key on Add Themes screen. 2022-08-19 13:11:14 +00:00
themes.php Themes: Properly escape `home_url()` when changing and updating themes. 2022-07-06 19:46:10 +00:00
tools.php
update-core.php Coding standards: Properly escape URLs returned by `self_admin_url()` calls. 2022-08-05 06:12:10 +00:00
update.php
upgrade-functions.php
upgrade.php General: Replace all `esc_url_raw()` calls in core with `sanitize_url()`. 2022-06-01 18:14:10 +00:00
upload.php Help/About: Typo correction in the Media Library help tab text. 2022-06-29 13:39:14 +00:00
user-edit.php Application Passwords: Link a more accurate documentation page in User profile edit screen. 2022-07-21 19:32:12 +00:00
user-new.php Users: Use autocomplete values on user profiles. 2022-04-08 17:40:07 +00:00
users.php Help/About: Add help tab info for the "Send password reset" row action on Users screen. 2022-07-05 00:25:13 +00:00
widgets-form-blocks.php Editor: Update preload paths for post, site and widgets editors 2022-04-07 13:40:04 +00:00
widgets-form.php
widgets.php Administration: Replace contracted verb forms for better consistency. 2022-03-22 19:59:04 +00:00