-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(metadata): Refactor metadata #56
Conversation
573a5c9
to
21c2992
Compare
Ready for review |
3f9c2e8
to
19277a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small stuff, LGTM otherwise 👍
* @param mixed $value Value to map | ||
* @param array $context Options mapper have access to | ||
* @param mixed $value Value to map | ||
* @param array<string, mixed> $context Options mapper have access to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we make an object to have a better typing there ? Or maybe it's too much for now and can be done later on ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but can be in another PR, this one is already big enough maybe create an issue to discuss on what to do for the context options in 9.0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair 👍
@@ -50,12 +50,12 @@ public function supportsNormalization(mixed $data, string $format = null, array | |||
return false; | |||
} | |||
|
|||
return $this->autoMapper->hasMapper($data::class, 'array'); | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it's something we can't map ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can always map :)
a68a018
to
d965f8d
Compare
d965f8d
to
90aaf91
Compare
* feat(metadata): Refactor metadata (#56) * feat(metadata): Refactor metadata, split them depending on their roles, adapt transform interface with them * feat(transformer): remove callback transformer * feat(extractor): remove callback extractor * feat(transformer): remove deprecation trigger * chore(api): add internal everywhere it makes sense * chore(cs): fix wrong case for variable * feat(mapper): be nice with typing * feat(event): add event system, make serializer optional * feat(event): move map to context implementation to event listener * feat(bundle): Merge bundle directly into automapper, will replace automapper-bundle (#63) * feat(bundle): Merge bundle directly into automapper, will replace automapper-bundle * Migrate to bundle PHP config * chore(doc): update doc with new configuration / bundle namespace * feat(bundle): add all possible configuration to the bundle --------- Co-authored-by: Baptiste Leduc <baptiste.leduc@gmail.com> * chore(deps): allow to use sf 5.4 for most things, remove useless deps / suggests (#68) * feat(attribute): add map to attribute * feat(map-to): add transformer support * feat(map-to): throw exception if there is the same map to attribute for the same target * Fixes * feat(map-to): better callable support for transformer * chore(doc): add documentation about MapTo attribute * feat(attribute): add map-from attribute * feat(map-to): make it works with methods * chore(typo): fix variable name * fix(map-to): split map to / map from, fix from array * fix(event): use interface for class metadata factory * fix(groups): don't map property if groups specified and no groups attached * fix(normalize): don't map unexisting context, fix target to populate * fix(transformer): check class exists when checking reflection class in object transformer factory * feat(types): use a new interface to check types during runtime * feat(types): use a type matching class for types, allow to make better relationship between types * fix(ast): use correct php parser class * feat(types): add doc on check type interface, use named parameters for event * Update AutoMapper version for 9.0 branch * fix(types): try to get types from read accessor / write mutator first * feat(type): add new type extractor into bundle * feat(map-to): add listeners to bundle * feat(transformer): refactor the way to create custom transformer * feat(if): add if feature to map to / map from attributes * feat(if): allow to use a callable for if * fix(types): correctly handle prometed properties * fix(types): add documentation about why we need this extractor * feat(map-to): allow map to / from attribute in class when declaring a transformer and a name * Update CHANGELOG * feat(attribute): add groups to map to / from attributes * fix(map-from): correctly use method from target if asked * feat(transformer): allow expression language for transformer, add provider for custom functions * feat(transformer): add attribute to automatically bind service to expression language in bundle * feat(bundle): allow to use eval loader instead of file * fix(proxy): get real class name when a proxy is mapped in automapper * fix(normalizer): don't normalize iterable object (array) * fix(transformer): use current instead of dimension fetching, allow array not indexed by int * fix(transformer): fix incorrect date time transformer guess * fix: add tests for iterable normalizer, real class name and date time * feat(mapper): correctly map from an inherited class * feat(normalizer): add normalizer format in context * feat(groups): add a flags to completly skip group checking for a property * feat(normalizer): remove registry interface from normalizer as not needed * chore(test): allow to run symfony app in tests * chore(doc): reorganize documentation structure * chore(doc): rewrite getting started and bundle part of the documentation * Fix documentation build * Fix documentation build * chore(doc): add doc about mapping * fix(serializer): fix map to overriding ignore / groups attribute from serializer * chore(type): fix most phpstan issues * Update CHANGELOG.md * feat(normalizer): allow normalizer to only work with registered mapping * feat(migrate): fix doc with new config, add migrate doc, add tests * feat(mapper): add a way to instantiate object in mapper with providers * Update CHANGELOG.md * Small fixes --------- Co-authored-by: Joel Wurtz <jwurtz@jolicode.com> Co-authored-by: Joel Wurtz <joel.wurtz@gmail.com>
This PR aim to improve metadata implementation in order to prepare the work for the attributes :
The goal will be that Attribute or other extension point only update those object to change how the generated code (like the name of the source / target property, if it's use the constructor, the date time format, if it's ignored, etc ....)
There is a lot of BC break, not sure if we could make it work with current version, i would merge this in a 9.0 with the new extensions point without doing a big layer for BC break, current change of interface are either new (8.2) or IMO too complicated / low level so that few people use them