mark-gerarts/automapper-plus

Problem with mapping substr names properties

ayacaste opened this issue · 4 comments

Hello! I updated from 1.2.1 to 1.2.2 and found a bug, example code:

final class FooDTO {
	/** @var int */
	private $foo_another_id = 2;
	/** @var int */
	private $id = 1;
}

final class BarDTO {
	/** @var int */
	private $id;
	/** @var int */
	private $bar_another_id;
}

$config = (new \AutoMapperPlus\Configuration\AutoMapperConfig());
$config
	->registerMapping(FooDTO::class, BarDTO::class)
	->forMember('id', \AutoMapperPlus\MappingOperation\Operation::fromProperty('id'))
	->forMember('bar_another_id', \AutoMapperPlus\MappingOperation\Operation::fromProperty('foo_another_id'))
	->withDefaultOperation(\AutoMapperPlus\MappingOperation\Operation::ignore());
$mapper = new \AutoMapperPlus\AutoMapper($config);
var_dump($mapper->map((new FooDTO()), BarDTO::class));

Output:

object(BarDTO)[539]
  private 'id' => int 2
  private 'bar_another_id' => int 2

Problem in \AutoMapperPlus\PropertyAccessor\PropertyAccessor::getPrivate

Hi, this most likely has to do with this commit. I'll try to take a look at it this evening, since this is a pretty severe bug. I'll keep you posted.

Ok, thank you.

I found some time to fix this a bit earlier; I've drafted a new release for it. If you still have issues, feel free to reopen. And thanks for the detailed bug report btw!

Cool, thanks a lot!