Problem/Motivation
PHP 8.2 has what is likely to be a hugely disruptive deprecation of dynamic properties. This is used through out core and likely to cause numerous problems. Obviously deprecation don't _break_ sites but they will introduce warnings into dev environments that capture deprecation errors and block support for PHP 9 where they will be errors.
https://wiki.php.net/rfc/deprecate_dynamic_properties
Steps to reproduce
You can compile php 8.2 and run a site and see a number of deprecation notices. Late 2022 php 8.2 should be released and we will be seeing these in phpstan and during testbot runs.
Proposed resolution
Fixes will vary. For data objects we can either add #[AllowDynamicProperties] or there is a simple-ish hack we can apply to support.
/**
* Raw row data.
*
* @var array
*/
private array $data = [];
/**
* Implements the magic method for getting object properties.
*
* @param $name
* Property name.
*
* @return mixed
* The property value.
*/
public function &__get($name) {
return $this->data[$name];
}
/**
* Implements the magic method to determines whether a property is set.
*
* @param $name
* Property name.
*
* @return bool
* True if property is set.
*/
public function __isset($name) {
return isset($this->data[$name]);
}
/**
* Implements the magic method to set a property.
*
* @param $name
* Property name.
* @param mixed $value
* The property value.
*/
public function __set($name, $value) {
$this->data[$name] = $value;
}
/**
* Implements the magic method to unset a property.
*
* @param $name
* Property name.
*/
public function __unset($name) {
unset($this->data[$name]);
}
Some things just don't work anymore #2531564: Fix leaky and brittle container serialization solution
Remaining tasks
- Create tasks for issues.
- Fix issues
User interface changes
n/a . This should only affect code interfaces.
API changes
Most changes should be to data objects or just missing properties so hopefully limited. I expect this will turn up some code smell that may result in deprecation though. Also we may find other hard changes like to our service container that require complicated fixes.
Data model changes
n/a
Release notes snippet
tbd