Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/bundle/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
![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<SourceType, TargetType>` 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.
8 changes: 4 additions & 4 deletions docs/mapping/type.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
```
Expand All @@ -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;
}
```
Expand Down
8 changes: 4 additions & 4 deletions tests/Bundle/ServiceInstantiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
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;
use Symfony\Component\HttpFoundation\Request;
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
{
Expand Down