Skip to content

Commit 71c6a60

Browse files
committed
use lazy ghost instead of proxy
1 parent 88edbd3 commit 71c6a60

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Symfony/Component/ObjectMapper/ObjectMapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private function doMap(object $source, object|string|null $target, \WeakMap $obj
169169
}
170170
}
171171

172-
if (!$mappingToObject && !$map?->transform && $targetConstructor) {
172+
if ((!$mappingToObject || !$rootCall) && !$map?->transform && $targetConstructor) {
173173
try {
174174
$mappedTarget->__construct(...$ctorArguments);
175175
} catch (\ReflectionException $e) {
@@ -246,11 +246,11 @@ private function getSourceValue(object $source, object $target, mixed $value, \W
246246
$refl = new \ReflectionClass($mapTo->target);
247247
$mapper = $this->objectMapper ?? $this;
248248

249-
return $refl->newLazyProxy(function () use ($mapper, $value, $objectMap, $mapTo) {
249+
return $refl->newLazyGhost(function ($target) use ($mapper, $value, $objectMap) {
250250
$previousMap = $this->objectMap;
251251
$this->objectMap = $objectMap;
252252
try {
253-
return $objectMap[$value] = $mapper->map($value, $mapTo->target);
253+
$objectMap[$value] = $mapper->map($value, $target);
254254
} finally {
255255
$this->objectMap = $previousMap;
256256
}

0 commit comments

Comments
 (0)