Skip to content

"Auto" Constructor Strategy fails to use abstract constructor with promoted properties #284

Open
@aegypius

Description

@aegypius

Hi, First of all thanks for your work !

It seems than the "Auto" constructor strategy struggle with this kind of readonly inheritence.

abstract readonly class Fruit
{
    public function __construct(
      public int $weight
   ) {}
}

final readonly class Banana extends Fruit {}

After deserialisation the "Banana" instance as not been correctly populated and a runtime error is raised :

Typed property Fruit::$weight must not be accessed before initialization

I managed to setup a test to demonstrate the behavior : https://github.com/aegypius/automapper-issue-284.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions