Commit 69f7789
authored
fix mapping array of enums to setter which expects array of enums (#280)
Fix #269
I found out that this bug was introduced in #230, to be more precise
this lines
[ArrayTransformerFactory](https://github.com/jolicode/automapper/blob/9.4.1/src/Transformer/ArrayTransformerFactory.php#L42-L45).
Before #230 `$targetCollections` would be equal `[]` so we would get
`return new DictionaryTransformer(new CopyTransformer());`. And
CopyTransformer would just pass enums from property to
`setPaymentMethods()`.
But simply removing this lines wouldn't work because they do serve they
purpose in fixing weird behavior in #230.
So I dug further and found out original issue.
Here
[WriteMutator](https://github.com/jolicode/automapper/blob/9.4.1/src/Extractor/WriteMutator.php#L160-L165)
should get that `setPaymentMethods()` expects `PaymentMethod[]` but gets
blocked here
[GetTypeTrait](https://github.com/jolicode/automapper/blob/9.4.1/src/Extractor/GetTypeTrait.php#L81)
because argument `$property` equals `'setPaymentMethods'` and we get
this check that result in false and we skip trying to extract types
```php
'$paymentMethods' !== '$setPaymentMethods'
```File tree
3 files changed
+52
-1
lines changed- src/Extractor
- tests/AutoMapperTest/Issue269
3 files changed
+52
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments