PHP-DYNAMIC-PROP-001
$this->foo = 1 on an untyped class
Dynamic PHP properties (PHP 8.2+)
Joomla 5/6 run on PHP 8.2–8.4. Creating undeclared properties is deprecated and will be removed. Joomla 3 code did this constantly.
$this->foo = 1 on an untyped class → Declare the property or use AllowDynamicProperties
What you will see
- Creation of dynamic property
- Deprecated: Creation of dynamic property
Symptoms people search
php 8.2 deprecation flood · dynamic property
Replace this code
Swap $this->foo = 1 on an untyped class for Declare the property or use AllowDynamicProperties.
Joomla 3
Remove or stop calling this
class LmsHelper {
public function set($k, $v) { $this->$k = $v; }
}Joomla 4 / 6
Use this instead
class LmsHelper {
public string $name;
}
// or #[\AllowDynamicProperties] as a last resortHow to fix it
- 1Declare properties on the class.
- 2Avoid #[AllowDynamicProperties] except as a temporary bridge.
Also known as
dynamic property · AllowDynamicProperties
Related issues
- Joomla 3 → 4PHP
jimport() autoloader calls
jimport('joomla.filesystem.file') → use Joomla\CMS\Filesystem\File;
- Joomla 3 → 4PHP
DS path constant
DS → DIRECTORY_SEPARATOR or /
- Joomla 3 → 4PHP
JPATH_PLATFORM
JPATH_PLATFORM → Do not use — autoload instead
- Joomla 3 → 4Events / plugins
JDispatcher / JEventDispatcher
JDispatcher::getInstance() → Event dispatcher + SubscriberInterface
- Joomla 3 → 4PHP
mysql_* PHP functions
mysql_query() → Joomla DatabaseInterface / mysqli / PDO
- Joomla 3 → 4PHP
each() / create_function() / ereg / split
each($array) → foreach / closures / preg_*