Skip to content

Commit 60215c6

Browse files
committed
review
1 parent dfb6950 commit 60215c6

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/Symfony/Component/ObjectMapper/ObjectMapper.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class ObjectMapper implements ObjectMapperInterface, ObjectMapperAwareInte
3232
/**
3333
* Tracks recursive references.
3434
*/
35-
private ?\WeakMap $objectMap = null;
35+
private \WeakMap $objectMap;
3636

3737
public function __construct(
3838
private readonly ObjectMapperMetadataFactoryInterface $metadataFactory = new ReflectionObjectMapperMetadataFactory(),
@@ -227,17 +227,15 @@ private function getSourceValue(object $source, object $target, mixed $value, \W
227227
$value = $target;
228228
} elseif ($objectMap->offsetExists($value)) {
229229
$value = $objectMap[$value];
230+
} elseif (\PHP_VERSION_ID < 80400) {
231+
return ($this->objectMapper ?? $this)->map($value, $mapTo->target);
230232
} else {
231-
if (\PHP_VERSION_ID >= 80400) {
232-
$refl = new \ReflectionClass($mapTo->target);
233-
$mapper = $this->objectMapper ?? $this;
234-
235-
return $refl->newLazyProxy(static function () use ($mapper, $value, $objectMap, $mapTo) {
236-
return $objectMap[$value] = $mapper->map($value, $mapTo->target);
237-
});
238-
}
233+
$refl = new \ReflectionClass($mapTo->target);
234+
$mapper = $this->objectMapper ?? $this;
239235

240-
return ($this->objectMapper ?? $this)->map($value, $mapTo->target);
236+
return $refl->newLazyProxy(static function () use ($mapper, $value, $objectMap, $mapTo) {
237+
return $objectMap[$value] = $mapper->map($value, $mapTo->target);
238+
});
241239
}
242240
}
243241

0 commit comments

Comments
 (0)