diff --git a/CHANGELOG.md b/CHANGELOG.md index f119f67..8cdf3c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.5.4 * Add a caching layer for `TypeResolver` +* `TraversableToTraversableTransformer` now accepts `Generator` as a target type ## 0.5.3 diff --git a/src/Transformer/TraversableToTraversableTransformer.php b/src/Transformer/TraversableToTraversableTransformer.php index 0e2e753..4b590a3 100644 --- a/src/Transformer/TraversableToTraversableTransformer.php +++ b/src/Transformer/TraversableToTraversableTransformer.php @@ -168,6 +168,7 @@ public function getSupportedTransformation(): iterable ]; $targetTypes = [ + TypeFactory::objectOfClass(\Generator::class), TypeFactory::objectOfClass(\Traversable::class), ]; diff --git a/tests/IntegrationTest/TraversableToTraversableMappingTest.php b/tests/IntegrationTest/TraversableToTraversableMappingTest.php index 2154cbb..52ae7ae 100644 --- a/tests/IntegrationTest/TraversableToTraversableMappingTest.php +++ b/tests/IntegrationTest/TraversableToTraversableMappingTest.php @@ -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); @@ -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);