[wp-trac] [WordPress Trac] #56514: PHP 8.2: fix magic method use within the test suite

WordPress Trac noreply at wordpress.org
Mon Sep 5 12:59:17 UTC 2022


#56514: PHP 8.2: fix magic method use within the test suite
--------------------------+-----------------------------
 Reporter:  jrf           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  6.1
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:  has-patch php82
  Focuses:                |
--------------------------+-----------------------------
 Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2
 and are expected to become a fatal error in PHP 9.0, though this last part
 is not 100% certain yet.

 RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties

 We can basically categorize dynamic properties into four base situations:

 || ||= Situation =||= Solution =||
 || 1. || Typo in property name || Fix the typo, either in the property as
 declared or where the property assignment happens ||
 || 2. || Known, named, dynamic property || Declare the property on the
 (parent) class ||
 || 3. || Known use of unknown dynamic properties || Declare the full set
 of magic methods on a class (preferred) or let the class extend `stdClass`
 (discouraged) ||
 || 4. || Unknown use of unknown dynamic properties || Use the
 `#[AllowDynamicProperties]` attribute on the (parent) class and/or declare
 the full set of magic methods on a class and/or let the class extend
 `stdClass` ||

 Note: the `#[AllowDynamicProperties]` attribute is expected to be a
 temporary solution and it is expected that support for the attribute will
 be removed from PHP at some point in the future.

 === Current status

 Patches have been created for Trac #56033 to explicitly declare all
 "known" dynamic properties (type 1 + 2).

 A proposal to mitigate the deprecation for the "unknown" dynamic
 properties (type 3 + 4) via traits is open in Trac #56034.


 === Magic methods

 A deep-dive into the magic methods implemented in WP Core has shown that
 most, if not all will need additional fixes.

 For those magic methods in the WP Core `src`, this will be addressed as
 part of Trac #56034.

 This ticket intends to address fixing the magic methods in the WP Core
 test suite.

 The necessary patches for this are already available via open PRs on
 GitHub:
 * https://github.com/WordPress/wordpress-develop/pull/3126
 * https://github.com/WordPress/wordpress-develop/pull/3130

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56514>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list