Add the AllowDynamicProperties
attribute to all classes
namespace Example\Domain;
+#[AllowDynamicProperties]
class SomeObject {
public string $someProperty = 'hello world';
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector;
return RectorConfig::configure()
->withConfiguredRule(AddAllowDynamicPropertiesAttributeRector::class, [
'Example\*',
]);