Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Automapper] private properties in constructor are not mapped #749

Closed
nikophil opened this issue Aug 22, 2023 · 1 comment
Closed

[Automapper] private properties in constructor are not mapped #749

nikophil opened this issue Aug 22, 2023 · 1 comment
Labels

Comments

@nikophil
Copy link
Contributor

Jane version(s) affected: 7.5.3

Description
a private property in the constructor without any getter/setter will not be mapped

How to reproduce
The following code will create an error, because the generated mapper will be empty

class SomeClass
{
    public function __construct(
        private string $someProp
    ){}
}

$automapper->map(['someProp' => 'foo'], SomeClass::class);

Possible Solution
dig in the generator and allow this kind of props

@nikophil nikophil added the bug label Aug 22, 2023
@nikophil
Copy link
Contributor Author

nikophil commented Sep 8, 2023

this is actually coming from Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor, and can be fixed by passing ReflectionExtractor::ALLOW_PUBLIC | ReflectionExtractor::ALLOW_PROTECTED | ReflectionExtractor::ALLOW_PRIVATE to $accessFlaf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant