mark-gerarts/automapper-plus

Typed properties break mapping operations

shadowhand opened this issue · 3 comments

Having a typed property (PHP 7.4+), such as:

class Employee
{
    public string $name;
    public int $age;
}

Causes mapping operations to fail when mapping to Employee::class. The same mapping operating works fine if the properties are declared without types.

Thanks for letting me know, this breaks because typed properties without a value are not initialized internally. As a quick solution you can add a default value, e.g. public string $name = ''.

In the meantime I'll have to rework the PropertyAccessor.

Hi @shadowhand, the new version (1.3.11) includes a fix, let me know if you encounter any more issues!

@mark-gerarts thank you so much for the fast response!