#106565Constructor Promotion Not Supported in Extbase Domain Models
Description
When using PHP 8+ constructor property promotion in Extbase domain models (classes extending \TYPO3\CMS\Extbase\DomainObject\AbstractEntity), the promoted properties are not persisted, hydrated, or validated as expected.
Although promoted properties are real class properties (per PHP), Extbase does not treat them equivalently to explicitly declared properties. This leads to unexpected behavior when persisting or retrieving entities from the database.
When using:
class Blog extends AbstractEntity
{
public function __construct(
#[Lazy]
#[Cascade(['value' => 'remove'])]
public ObjectStorage $posts = new ObjectStorage()
) {}
}
The behaviour is not the same like for
class Blog extends AbstractEntity
{
#[Lazy]
#[Cascade(['value' => 'remove'])]
protected ObjectStorage $posts;
public function __construct()
{
$this->posts = new ObjectStorage();
}
public function getPosts(): ObjectStorage
{
return $this->posts;
}
}
When I write a test in which I change typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Domain/Model/Blog.php
To constructor promotion there are currently 12 errors and 1 failute in the functional extbase tests.