Skip to content

Commit

Permalink
fix: NullTransformer bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Jan 14, 2024
1 parent b6b1cf6 commit c6e09a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* feat: Transformers now have the option to have an invariant target type.
* fix: Wrong service id for `CopyTransformer`.
* fix: Remove cache file & regenerate it if it is corrupt.
* fix: `NullTransformer` bug.

## 0.5.8

Expand Down
6 changes: 5 additions & 1 deletion src/Transformer/NullTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ public function transform(
return [];
}

throw new InvalidArgumentException(sprintf('Target must be scalar, "%s" given', get_debug_type($targetType)), context: $context);
if (TypeCheck::isNull($targetType)) {
return null;
}

throw new InvalidArgumentException(sprintf('Target must be scalar, "%s" given.', get_debug_type($targetType)), context: $context);
}

public function getSupportedTransformation(): iterable
Expand Down

0 comments on commit c6e09a1

Please sign in to comment.