Exclude properties based on semver constraints#1361
Conversation
79bc13e to
62d92f6
Compare
be9c84f to
8e50c6b
Compare
…sion constraints accepted by composer
8e50c6b to
c2a0e19
Compare
@scyzoryck Good point. I think they should be deprecated since version constraints provide even more flexibility. Do you agree? |
|
Thanks. Looks good to me.
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? |
| class VersionedObject | ||
| { | ||
| /** | ||
| * @Until("1.0.x") |
There was a problem hiding this comment.
I would not abandon @Until and @Since , mainly for performance reasons. my guess is that composer/semver is way slower that the php's version_compare function, in a large object graph in it can make the difference.
I think that it could be also mentioned in the documentation the potential performance impact.
BTW, i would be curious to see a benchmark about it
| { | ||
| public function __construct($values = [], ?string $version = null) | ||
| { | ||
| if (!class_exists(Semver::class)) { |
There was a problem hiding this comment.
what if this check is done in the metadata drivers? so we avoid to call it at runtime each time the annotation is instantiated?
This PR adds the possibility to exclude properties from serialization based on version constraints accepted by composer.
Example:
I'm not sure if
VersionConstraintsis a good name or if there are better alternatives. Suggestions are welcome :)