Skip to content

Commit a5dda1a

Browse files
authored
Merge pull request #322 from jolicode/feature/rework-documentation
Add missing stuff in documentation
2 parents 705df0e + b331973 commit a5dda1a

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

docs/bundle/debugging.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@ generated during the request it will not be displayed.
2222
You can find the panel in the Symfony profiler under the `AutoMapper` tab.
2323

2424
![Profiler](../images/debug-profiler-1.png)
25-
![Profiler](../images/debug-profiler-2.png)
25+
![Profiler](../images/debug-profiler-2.png)
26+
27+
## What is displayed
28+
29+
Both the debug command and the profiler show the same kind of information for each mapper:
30+
31+
- **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.
32+
- **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).
33+
- **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).
34+
35+
In the profiler, you can also use **Show Code** for each property to see the exact generated PHP snippet that performs the mapping.

docs/mapping/type.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ like an array or `\stdClass`, the property type is not available.
77

88
In this case the type is, by default, transformed to a native PHP type (`int`, `float`, `string`, `bool`, `array`, `object`, `null`).
99

10-
You can override this behavior by specifying the `sourcePropertyType` or `targetPropertyType` argument in the
11-
`#[MapTo]` or `#[MapFrom]` attributes.
10+
You can override this behavior by specifying the `sourcePropertyType` or `targetPropertyType` argument in the `#[MapTo]` or
11+
`#[MapFrom]` attributes. You can override the source type, the target type, or both, depending on the mapping direction.
1212

1313
```php
1414
class Entity
1515
{
16-
#[MapTo(target: 'array', targetPropertyType: 'int']
16+
#[MapTo(target: 'array', targetPropertyType: 'int')]
1717
public string $number;
1818
}
1919
```
@@ -25,7 +25,7 @@ This can also be useful when mapping to an object type with an union type, but y
2525
```php
2626
class EntityDto
2727
{
28-
#[MapTo(target: Entity:class, sourcePropertyType: 'int']
28+
#[MapTo(target: Entity::class, sourcePropertyType: 'int')]
2929
private int|float $value;
3030
}
3131
```

tests/Bundle/ServiceInstantiationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
use AutoMapper\Tests\Bundle\Resources\App\Entity\SomeEnum;
2121
use AutoMapper\Tests\Bundle\Resources\App\Entity\User;
2222
use AutoMapper\Tests\Bundle\Resources\App\Entity\UserDTO;
23+
use AutoMapper\Tests\ObjectMapper\Fixtures\A;
24+
use AutoMapper\Tests\ObjectMapper\Fixtures\B;
25+
use AutoMapper\Tests\ObjectMapper\Fixtures\C;
26+
use AutoMapper\Tests\ObjectMapper\Fixtures\D;
2327
use PHPUnit\Framework\Attributes\DataProvider;
2428
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
2529
use Symfony\Component\Filesystem\Filesystem;
2630
use Symfony\Component\HttpFoundation\Request;
2731
use Symfony\Component\HttpFoundation\Response;
2832
use Symfony\Component\HttpKernel\KernelInterface;
2933
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
30-
use AutoMapper\Tests\ObjectMapper\Fixtures\A;
31-
use AutoMapper\Tests\ObjectMapper\Fixtures\B;
32-
use AutoMapper\Tests\ObjectMapper\Fixtures\C;
33-
use AutoMapper\Tests\ObjectMapper\Fixtures\D;
3434

3535
class ServiceInstantiationTest extends WebTestCase
3636
{

0 commit comments

Comments
 (0)