Skip to main content

Mapping Table

When we tell the mapper to map a source to a target, it will look up the mapping table to find the correct transformer for the job, then tells the transformer to do the mapping. It does that first for the root source and target pair, then traverses down the properties and does the same for each property.

Each transformer supplies a list of supported source to target mappings. The mapping table is constructed from the source and target types supported by each of the transformers registered in the system.

Mapping Table Properties

A row in the mapping table has the following properties:

  • Ordering number. Transformers have a priority. A mapping entry generated by a transformer with a higher priority will be checked earlier than those generated by one with a lower priority.
  • Source and target type pair.
  • Target variance. Invariant means the target type must be exactly the same as specified in the mapping table. Variant means the target type can also be a subclass of the type specified in the mapping table. Note that the source type is always variant.
  • Transformer service ID.

Viewing the Mapping Table

To inspect the mapping table, you can use the rekalogika:mapper:mapping command:

$ php bin/console rekalogika:mapper:mapping

The Mapper panel of the Symfony Profiler also shows the mapping table.

Default Mapping Table

OrderingSource TypeTarget TypeTarget VarianceClass
1nullnullinvariantNullToNullTransformer
2intintinvariantScalarToScalarTransformer
3intfloatinvariantScalarToScalarTransformer
4intstringinvariantScalarToScalarTransformer
5intboolinvariantScalarToScalarTransformer
6floatintinvariantScalarToScalarTransformer
7floatfloatinvariantScalarToScalarTransformer
8floatstringinvariantScalarToScalarTransformer
9floatboolinvariantScalarToScalarTransformer
10stringintinvariantScalarToScalarTransformer
11stringfloatinvariantScalarToScalarTransformer
12stringstringinvariantScalarToScalarTransformer
13stringboolinvariantScalarToScalarTransformer
14boolintinvariantScalarToScalarTransformer
15boolfloatinvariantScalarToScalarTransformer
16boolstringinvariantScalarToScalarTransformer
17boolboolinvariantScalarToScalarTransformer
18stringDateTimeInterfaceinvariantDateTimeTransformer
19stringDateTimeinvariantDateTimeTransformer
20stringDateTimeImmutableinvariantDateTimeTransformer
21stringDatePointinvariantDateTimeTransformer
22DateTimeInterfaceDateTimeInterfaceinvariantDateTimeTransformer
23DateTimeInterfaceDateTimeinvariantDateTimeTransformer
24DateTimeInterfaceDateTimeImmutableinvariantDateTimeTransformer
25DateTimeInterfaceDatePointinvariantDateTimeTransformer
26DateTimeInterfacestringinvariantDateTimeTransformer
27stringBackedEnumvariantStringToBackedEnumTransformer
28MapToObjectInterfaceobjectvariantClassMethodTransformer
29objectMapFromObjectInterfacevariantClassMethodTransformer
30StringablestringinvariantObjectToStringTransformer
31UnitEnumstringinvariantObjectToStringTransformer
32TraversableCollectioninvariantTraversableToArrayAccessTransformer
33TraversableReadableCollectioninvariantTraversableToArrayAccessTransformer
34TraversableArrayCollectioninvariantTraversableToArrayAccessTransformer
35TraversableArrayObjectinvariantTraversableToArrayAccessTransformer
36TraversableArrayIteratorinvariantTraversableToArrayAccessTransformer
37TraversableArrayAccessinvariantTraversableToArrayAccessTransformer
38TraversableCollectionInterfaceinvariantTraversableToArrayAccessTransformer
39TraversablearrayinvariantTraversableToArrayAccessTransformer
40arrayCollectioninvariantTraversableToArrayAccessTransformer
41arrayReadableCollectioninvariantTraversableToArrayAccessTransformer
42arrayArrayCollectioninvariantTraversableToArrayAccessTransformer
43arrayArrayObjectinvariantTraversableToArrayAccessTransformer
44arrayArrayIteratorinvariantTraversableToArrayAccessTransformer
45arrayArrayAccessinvariantTraversableToArrayAccessTransformer
46arrayCollectionInterfaceinvariantTraversableToArrayAccessTransformer
47arrayarrayinvariantTraversableToArrayAccessTransformer
48TraversableTraversableinvariantTraversableToTraversableTransformer
49arrayTraversableinvariantTraversableToTraversableTransformer
50objectarrayinvariantObjectToArrayTransformer
51arrayobjectvariantArrayToObjectTransformer
52objectobjectvariantObjectToObjectTransformer
53nullstringinvariantNullTransformer
54nullintinvariantNullTransformer
55nullfloatinvariantNullTransformer
56nullboolinvariantNullTransformer
57nullarrayinvariantNullTransformer
58mixednullinvariantNullTransformer
59mixedmixedvariantCopyTransformer