[wp-trac] [WordPress Trac] #56034: PHP 8.2: proposal for handling unknown dynamic properties deprecations

WordPress Trac noreply at wordpress.org
Tue Apr 30 12:56:52 UTC 2024


#56034: PHP 8.2: proposal for handling unknown dynamic properties deprecations
----------------------------+--------------------------------
 Reporter:  jrf             |       Owner:  hellofromTonya
     Type:  task (blessed)  |      Status:  accepted
 Priority:  normal          |   Milestone:  6.6
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  php82           |     Focuses:  php-compatibility
----------------------------+--------------------------------

Comment (by antonvlasenko):

 I'd like to highlight a point not previously mentioned in the discussion.
 When implementing the missing magic methods in the class, it may be
 beneficial to allow setting of public properties that were previously
 unset but now need to be assigned new values. Here’s an example to
 clarify:
 {{{
 class Foo {
     public $property;
 }

 $foo = new Foo();
 unset( $foo->property );
 $foo->property = 'some_value'; // Note that PHP doesn't trigger a
 deprecation error, so the magic method shouldn't throw one either.
 }}}

 If the `__set` method was defined for the Foo class, it should have
 allowed `Foo::$property` to be reassigned, even if it had been previously
 unset.
 This might help improve backward compatibility while ensuring that dynamic
 properties are properly handled.

 For a more detailed illustration of this idea, please see the
 `Baz::__set()` method in following code snippet:
 https://3v4l.org/QU0tT#v8.3.6.

 This is also true for other magic methods, such as `__get`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56034#comment:70>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list