Skip to content

Commit

Permalink
TraversableToTraversableTransformer now accepts Generator as a ta…
Browse files Browse the repository at this point in the history
…rget type
  • Loading branch information
priyadi committed Jan 11, 2024
1 parent bb817f7 commit 73c6128
Show file tree
Hide file tree
Showing 3 changed files with 4 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.4

* Add a caching layer for `TypeResolver`
* `TraversableToTraversableTransformer` now accepts `Generator` as a target type

## 0.5.3

Expand Down
1 change: 1 addition & 0 deletions src/Transformer/TraversableToTraversableTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function getSupportedTransformation(): iterable
];

$targetTypes = [
TypeFactory::objectOfClass(\Generator::class),
TypeFactory::objectOfClass(\Traversable::class),
];

Expand Down
2 changes: 2 additions & 0 deletions tests/IntegrationTest/TraversableToTraversableMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function testTraversableToTraversableDto(): void

$this->assertInstanceOf(ObjectWithTraversablePropertyDto::class, $result);
$this->assertNotNull($result->property);
$this->assertInstanceOf(\Generator::class, $result->property);

foreach ($result->property as $item) {
$this->assertInstanceOf(ObjectWithScalarPropertiesDto::class, $item);
Expand All @@ -52,6 +53,7 @@ public function testArrayToTraversableDto(): void

$this->assertInstanceOf(ObjectWithTraversablePropertyDto::class, $result);
$this->assertNotNull($result->property);
$this->assertInstanceOf(\Generator::class, $result->property);

foreach ($result->property as $item) {
$this->assertInstanceOf(ObjectWithScalarPropertiesDto::class, $item);
Expand Down

0 comments on commit 73c6128

Please sign in to comment.