Skip to content

Commit 129ee56

Browse files
authored
Merge pull request #35 from rekalogika:feat/dynamic-property-scalar
perf(`ObjectToObjectTransformer`): Prevent delegating to `MainTransformer` if the current value in a dynamic property is a scalar.
2 parents 9d8e927 + af8fbfa commit 129ee56

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* fix: mapping to object extending `stdClass` to property with no setter.
2020
* feat: `stdClass` to `stdClass` mapping should work correctly.
2121
* feat: Mapping to existing values in a dynamic property.
22+
* perf(`ObjectToObjectTransformer`): Prevent delegating to `MainTransformer` if
23+
the current value in a dynamic property is a scalar.
2224

2325
## 1.0.0
2426

src/Transformer/Implementation/ObjectToObjectTransformer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,10 @@ private function mapDynamicProperties(
587587
}
588588

589589

590-
if ($currentTargetPropertyValue === null) {
590+
if (
591+
$currentTargetPropertyValue === null
592+
|| is_scalar($currentTargetPropertyValue)
593+
) {
591594
/** @psalm-suppress MixedAssignment */
592595
$targetPropertyValue = $sourcePropertyValue;
593596
} else {

0 commit comments

Comments
 (0)