rfc:deprecate_dynamic_properties

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
rfc:deprecate_dynamic_properties [2021/10/12 10:07] – Use attribute instead nikicrfc:deprecate_dynamic_properties [2021/10/12 10:16] nikic
Line 4: Line 4:
   * Status: Under Discussion   * Status: Under Discussion
   * Target Version: PHP 8.2   * Target Version: PHP 8.2
-  * Implementation: https://github.com/php/php-src/pull/7390+  * Implementation: https://github.com/php/php-src/pull/7571
  
 ===== Introduction ===== ===== Introduction =====
Line 98: Line 98:
 </PHP> </PHP>
  
-For classes that intentionally don't have a fixed set of properties, it's possible to either implement magic ''%%__get()%%''/''%%__set()%%'' or mark the class using the ''#[AllowDynamicProperties]'' attribute. Marking a class with ''#[AllowDynamicProperties]'' is fully backwards-compatible with earlier PHP version, because prior to PHP 8.0 this would be interpreted as a comment, and the use non-existent classes as attributes is not an error.+For classes that intentionally don't have a fixed set of properties, it's possible to either implement magic ''%%__get()%%''/''%%__set()%%'' or mark the class using the ''#[AllowDynamicProperties]'' attribute. Marking a class with ''#[AllowDynamicProperties]'' is fully backwards-compatible with earlier PHP versions, because prior to PHP 8.0 this would be interpreted as a comment, and the use non-existent classes as attributes is not an error.
  
 In some cases it is desirable to associate information with objects that you do not own. Previously, it was possible to add a dynamic property for this purpose. Instead, a ''WeakMap'' should be used to store the information in a non-intrusive way: In some cases it is desirable to associate information with objects that you do not own. Previously, it was possible to add a dynamic property for this purpose. Instead, a ''WeakMap'' should be used to store the information in a non-intrusive way:
rfc/deprecate_dynamic_properties.txt · Last modified: 2021/11/26 13:59 by nikic