Skip to content

Commit

Permalink
fix(MainTransformer): Fix possible bug involving an existing target.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jan 15, 2024
1 parent 0555d64 commit 9e90c74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* test: Mapping test first version.
* refactor: rename `RefuseToHandleException` to `RefuseToTransformException`.
* perf(`CopyTransformer`): Move identity check to the beginning.
* fix(`MainTransformer`): Fix possible bug involving an existing target.

## 0.5.10

Expand Down
13 changes: 8 additions & 5 deletions src/MainTransformer/MainTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ public function transform(
Context $context,
string $path = null,
): mixed {
// if targettype is not provided, guess it from target
// if the target is also missing then the target is mixed
// if target is provided, guess the type from it.
// if target is not provided, use the provided target type. if it is
// also not provided, then the target type is mixed.

if (count($targetTypes) === 0) {
if ($target === null) {
if ($target === null) {
if (count($targetTypes) === 0) {
$targetTypes = [MixedType::instance()];
} else {
}
} else {
if (count($targetTypes) === 0) {
$targetTypes = [$this->typeResolver->guessTypeFromVariable($target)];
}
}
Expand Down

0 comments on commit 9e90c74

Please sign in to comment.