Skip to content

Commit

Permalink
fix: Add variance safeguard.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jan 16, 2024
1 parent d2e2d30 commit 62e5260
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.5.13

* docs: Add rationale.
* fix: Add variance safeguard.

## 0.5.12

Expand Down
8 changes: 8 additions & 0 deletions src/Mapping/MappingEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ public function getClass(): string

public function isVariantTargetType(): bool
{
if ($this->targetType instanceof MixedType) {
return true;
}

if ($this->targetType->getBuiltinType() !== Type::BUILTIN_TYPE_OBJECT) {
return false;
}

return $this->variantTargetType;
}

Expand Down
8 changes: 8 additions & 0 deletions src/TransformerRegistry/SearchResultEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public function getMappingOrder(): int

public function isVariantTargetType(): bool
{
if ($this->targetType instanceof MixedType) {
return true;
}

if ($this->targetType->getBuiltinType() !== Type::BUILTIN_TYPE_OBJECT) {
return false;
}

return $this->variantTargetType;
}

Expand Down

0 comments on commit 62e5260

Please sign in to comment.