You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use AutoMapper to map a nested array structure to a nested model type in Symfony, an error occurs due to the configuration in Symfony\Component\PropertyInfo\Type, which sets the collection attribute to true for nested arrays. As a result, AutoMapper interprets the endpoints property as an array rather than an object of type TestSubTarget, causing a TypeError.
Here’s a simplified version of the mapping logic to reproduce the issue:
class ClassContainer
{
public ?array$endpoints = null;
}
class TestSubTarget
{
publicfunction__construct(
private ?string$endpoint = null,
private ?array$params = null,
) {}
}
class TestTarget
{
publicfunction__construct(
private ?TestSubTarget$endpoints = null,
) {}
}
When trying to use AutoMapper to map a nested array structure to a nested model type in Symfony, an error occurs due to the configuration in
Symfony\Component\PropertyInfo\Type
, which sets thecollection
attribute totrue
for nested arrays. As a result, AutoMapper interprets theendpoints
property as an array rather than an object of typeTestSubTarget
, causing aTypeError
.Here’s a simplified version of the mapping logic to reproduce the issue:
Steps to reproduce:
This triggers the error:
It would be great to have an option to override the collection type or manually specify the target type for nested arrays in AutoMapper.
Automapper version: 9.1.2
The text was updated successfully, but these errors were encountered: