[ 'value' => 'foo', ], ]; foreach ([ObjectValues::class, ObjectValuesWithConstructor::class] as $class) { try { $result = $this->mapperBuilder->mapper()->map($class, $source); } catch (MappingError $error) { $this->mappingFail($error); } self::assertSame('foo', $result->object->value); } } } class ObjectValues { public SimpleObject $object; } class ObjectValuesWithConstructor extends ObjectValues { public function __construct(SimpleObject $object) { $this->object = $object; } }