diff --git a/docs/bundle/debugging.md b/docs/bundle/debugging.md index d68bb89..72ca187 100644 --- a/docs/bundle/debugging.md +++ b/docs/bundle/debugging.md @@ -22,4 +22,14 @@ generated during the request it will not be displayed. You can find the panel in the Symfony profiler under the `AutoMapper` tab. ![Profiler](../images/debug-profiler-1.png) -![Profiler](../images/debug-profiler-2.png) \ No newline at end of file +![Profiler](../images/debug-profiler-2.png) + +## What is displayed + +Both the debug command and the profiler show the same kind of information for each mapper: + +- **Property types:** For each mapped property, the source and target property names are shown **with their types** (e.g. `title (string) -> name (string)`). This helps you see how AutoMapper interprets each property and which transformer will be used. +- **Transformer:** The transformer used for each property is displayed. When the transformer supports it, a detailed description is shown (e.g. `ObjectTransformer` for object-to-object mapping, or nested type information for array transformers). +- **Ignored / not used properties:** Properties that are not mapped are listed with the reason they are skipped (e.g. no matching source property, ignored by attribute, or condition not met). + +In the profiler, you can also use **Show Code** for each property to see the exact generated PHP snippet that performs the mapping. diff --git a/docs/mapping/type.md b/docs/mapping/type.md index 54ab6ee..d1215a4 100644 --- a/docs/mapping/type.md +++ b/docs/mapping/type.md @@ -7,13 +7,13 @@ like an array or `\stdClass`, the property type is not available. In this case the type is, by default, transformed to a native PHP type (`int`, `float`, `string`, `bool`, `array`, `object`, `null`). -You can override this behavior by specifying the `sourcePropertyType` or `targetPropertyType` argument in the -`#[MapTo]` or `#[MapFrom]` attributes. +You can override this behavior by specifying the `sourcePropertyType` or `targetPropertyType` argument in the `#[MapTo]` or +`#[MapFrom]` attributes. You can override the source type, the target type, or both, depending on the mapping direction. ```php class Entity { - #[MapTo(target: 'array', targetPropertyType: 'int'] + #[MapTo(target: 'array', targetPropertyType: 'int')] public string $number; } ``` @@ -25,7 +25,7 @@ This can also be useful when mapping to an object type with an union type, but y ```php class EntityDto { - #[MapTo(target: Entity:class, sourcePropertyType: 'int'] + #[MapTo(target: Entity::class, sourcePropertyType: 'int')] private int|float $value; } ``` diff --git a/tests/Bundle/ServiceInstantiationTest.php b/tests/Bundle/ServiceInstantiationTest.php index 2f56dcb..e2d0c8c 100644 --- a/tests/Bundle/ServiceInstantiationTest.php +++ b/tests/Bundle/ServiceInstantiationTest.php @@ -20,6 +20,10 @@ use AutoMapper\Tests\Bundle\Resources\App\Entity\SomeEnum; use AutoMapper\Tests\Bundle\Resources\App\Entity\User; use AutoMapper\Tests\Bundle\Resources\App\Entity\UserDTO; +use AutoMapper\Tests\ObjectMapper\Fixtures\A; +use AutoMapper\Tests\ObjectMapper\Fixtures\B; +use AutoMapper\Tests\ObjectMapper\Fixtures\C; +use AutoMapper\Tests\ObjectMapper\Fixtures\D; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Filesystem\Filesystem; @@ -27,10 +31,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\ObjectMapper\ObjectMapperInterface; -use AutoMapper\Tests\ObjectMapper\Fixtures\A; -use AutoMapper\Tests\ObjectMapper\Fixtures\B; -use AutoMapper\Tests\ObjectMapper\Fixtures\C; -use AutoMapper\Tests\ObjectMapper\Fixtures\D; class ServiceInstantiationTest extends WebTestCase {