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
class From
{
public array $values;
}
class To
{
public array $values;
}
$from = new From();
$to = new To();
$from->values = [1, 2, 3];
$to->values = [4, 5, 6];
$result = AutoMapper::create()->map($from, $to);
// $result->values is [1, 2, 3]
and approach with private/protected property and adder/remover
class From
{
public array $values;
}
class To
{
private array $values;
public function addValue(mixed $value): void
{
$this->values[] = $value;
}
public function removeValue(mixed $value): void
{
foreach ($this->values as $key => $existing) {
if ($value === $value) {
unset($this->values[$key]);
}
}
}
public function getValues(): array
{
return $this->values;
}
}
$from = new From();
$to = new To();
$from->values = [1, 2, 3];
$to->values = [4, 5, 6];
$result = AutoMapper::create()->map($from, $to);
// $result->values is [4, 5, 6, 1, 2, 3]
I believe this is also the cause for the issue outlined here
It seems like removerInfo is discarded and never used in the MappingExtractor leading to duplications.
Real use-case problem is mapping relations x-to-Many relations from DTOs to Doctrine collections, whereby whatever the expected behavior might be (and problems associated with it 169, 198, ), it is definitely not a duplication.
The text was updated successfully, but these errors were encountered:
There is incosistency in behavior between
and approach with private/protected property and adder/remover
I believe this is also the cause for the issue outlined here
It seems like removerInfo is discarded and never used in the MappingExtractor leading to duplications.
Real use-case problem is mapping relations x-to-Many relations from DTOs to Doctrine collections, whereby whatever the expected behavior might be (and problems associated with it 169, 198, ), it is definitely not a duplication.
The text was updated successfully, but these errors were encountered: