Skip to content

Commit

Permalink
fix: signature of Map attributes transformer property (#199)
Browse files Browse the repository at this point in the history
According to the `PropertyTransformerInterface`, the signature of a
transformer should be:

```php
/**
 * @param mixed                       $value   the value of the property to transform, can be null if there is no way to read the data from the mapping
 * @param object|array<string, mixed> $source  the source input on which the custom transformation applies
 * @param array<string, mixed>        $context Context during mapping
 */
public function transform(mixed $value, object|array $source, array $context): mixed;
```
  • Loading branch information
joelwurtz authored Oct 22, 2024
2 parents 253325d + 8159356 commit e959098
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/Attribute/MapFrom.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
final readonly class MapFrom
{
/**
* @param class-string<object>|'array'|array<class-string<object>|'array'>|null $source The specific source class name or array. If null this attribute will be used for all source classes.
* @param string|null $property The source property name. If null, the target property name will be used.
* @param int|null $maxDepth The maximum depth of the mapping. If null, the default max depth will be used.
* @param string|callable(mixed $value, object $object): mixed|null $transformer A transformer id or a callable that transform the value during mapping
* @param bool|null $ignore If true, the property will be ignored during mapping
* @param string|null $if The condition to map the property, using the expression language
* @param string[]|null $groups The groups to map the property
* @param string|null $dateTimeFormat The date-time format to use when transforming this property
* @param class-string<object>|'array'|array<class-string<object>|'array'>|null $source The specific source class name or array. If null this attribute will be used for all source classes.
* @param string|null $property The source property name. If null, the target property name will be used.
* @param int|null $maxDepth The maximum depth of the mapping. If null, the default max depth will be used.
* @param string|callable(mixed $value, object|array<string, mixed> $source, array<string, mixed> $context): mixed $transformer A transformer id or a callable that transform the value during mapping
* @param bool|null $ignore If true, the property will be ignored during mapping
* @param string|null $if The condition to map the property, using the expression language
* @param string[]|null $groups The groups to map the property
* @param string|null $dateTimeFormat The date-time format to use when transforming this property
*/
public function __construct(
public string|array|null $source = null,
Expand Down
16 changes: 8 additions & 8 deletions src/Attribute/MapTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
final readonly class MapTo
{
/**
* @param class-string<object>|'array'|array<class-string<object>|'array'>|null $target The specific target class name or array. If null this attribute will be used for all target classes.
* @param string|null $property The target property name. If null, the source property name will be used.
* @param int|null $maxDepth The maximum depth of the mapping. If null, the default max depth will be used.
* @param string|callable(mixed $value, object $object): mixed|null $transformer A transformer id or a callable that transform the value during mapping
* @param bool|null $ignore If true, the property will be ignored during mapping
* @param string|null $if The condition to map the property, using the expression language
* @param string[]|null $groups The groups to map the property
* @param string|null $dateTimeFormat The date-time format to use when transforming this property
* @param class-string<object>|'array'|array<class-string<object>|'array'>|null $target The specific target class name or array. If null this attribute will be used for all target classes.
* @param string|null $property The target property name. If null, the source property name will be used.
* @param int|null $maxDepth The maximum depth of the mapping. If null, the default max depth will be used.
* @param string|callable(mixed $value, object|array<string, mixed> $source, array<string, mixed> $context): mixed $transformer A transformer id or a callable that transform the value during mapping
* @param bool|null $ignore If true, the property will be ignored during mapping
* @param string|null $if The condition to map the property, using the expression language
* @param string[]|null $groups The groups to map the property
* @param string|null $dateTimeFormat The date-time format to use when transforming this property
*/
public function __construct(
public string|array|null $target = null,
Expand Down

0 comments on commit e959098

Please sign in to comment.