Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
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

Fix incomplete (Unbounded)QuantityValue::newFromArray deserializers #85

Merged
merged 1 commit into from
Aug 3, 2016

Conversation

thiemowmde
Copy link
Contributor

I consider this a "fix" for the following reason:

  • The parser returns either an unbounded or a bounded quantity value.
  • The formatter accepts both.
  • Both do have a getArrayValue method, which is what defines the serialization. The serializers don't know anything about the two classes.
  • We are considering the fact that we split the code into two classes an implementation detail.
  • Deserialization is done in DataValueDeserializer, which calls newFromArray. This should still be possible without requiring an "IF upper and lower bound are present THEN deserialize bounded quantity value ELSE deserialize unbounded quantity value". This knowledge should be inside of this component (because it is an implementation detail). Not in Wikibase.git.

@thiemowmde thiemowmde added this to the 0.8.1 milestone Aug 2, 2016
public static function newFromArray( array $data ) {
if ( !isset( $data['upperBound'] ) && !isset( $data['lowerBound'] ) ) {
return parent::newFromArray( $data );
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite unexpected, please add a warning or at least an explanation to the documentation.

Perhaps we should consider having a separate function for this - or even a QuantityValueFactory class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you expect whats not already in @return UnboundedQuantityValue|self?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, @return UnboundedQuantityValue|self is complete, but it's easy to miss. Since we are doing something quite unexpected (returning an incompatible object from a pseudo-constructor), a @warning seems in order.

@brightbyte
Copy link

+1 from me, +2 with better documentation.

@thiemowmde
Copy link
Contributor Author

Much, much simpler now. The fact that the implementation is split into two classes is considered an implementation detail. It's intended that the classes know each other, in both directions. There should only be one of these static newFromArray constructors.

@brightbyte brightbyte merged commit f3d5e64 into master Aug 3, 2016
@brightbyte brightbyte deleted the quantityBuilder branch August 3, 2016 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants