serializer
serializer copied to clipboard
Exclude properties based on semver constraints
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
Doc updated | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #1312 |
License | MIT |
This PR adds the possibility to exclude properties from serialization based on version constraints accepted by composer.
Example:
use JMS\Serializer\Annotation\VersionConstraints;
class Author
{
#[VersionConstraints('^6.1')]
public function getAge(): int
{
return 61;
}
}
I'm not sure if VersionConstraints
is a good name or if there are better alternatives. Suggestions are welcome :)
Do you think that we should keep
Until
andSince
attributes or they should be deprecated?
@scyzoryck Good point. I think they should be deprecated since version constraints provide even more flexibility. Do you agree?
Thanks. Looks good to me.
I think they should be deprecated since version constraints provide even more flexibility. Do you agree?
It was my initial thought - as basically new constraint covers all functionalities provided by older constraints. On the other hand new one requires external dependency, so keeping simpler constraints might made sense too. @goetas - what do you think about it?