File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99* Removed ` ReferenceList::removeDuplicates `
1010* ` ReferenceList ` no longer derives from ` SplObjectStorage ` , though still implements ` Countable `
1111* Removed ` HashableObjectStorage `
12+ * Added ` EntityDocument::equals `
13+ * ` Entity ` no longer implements ` Comparable `
1214
1315#### Other changes
1416
Original file line number Diff line number Diff line change 22
33namespace Wikibase \DataModel \Entity ;
44
5- use Comparable ;
6- use Wikibase \DataModel \Statement \Statement ;
75use Wikibase \DataModel \Term \AliasGroup ;
86use Wikibase \DataModel \Term \AliasGroupList ;
97use Wikibase \DataModel \Term \FingerprintHolder ;
1917 * @licence GNU GPL v2+
2018 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
2119 */
22- abstract class Entity implements Comparable, FingerprintHolder, EntityDocument {
20+ abstract class Entity implements FingerprintHolder, EntityDocument {
2321
2422 /**
2523 * Sets the value for the label in a certain value.
Original file line number Diff line number Diff line change @@ -52,4 +52,16 @@ public function setId( $id );
5252 */
5353 public function isEmpty ();
5454
55+ /**
56+ * Two entities are considered equal if they are of the same
57+ * type and have the same value. The value does not include
58+ * the id, so entities with the same value but different id
59+ * are considered equal.
60+ *
61+ * @param EntityDocument $entity
62+ *
63+ * @return bool
64+ */
65+ public function equals ( EntityDocument $ entity );
66+
5567}
Original file line number Diff line number Diff line change @@ -300,28 +300,23 @@ public function setStatements( StatementList $statements ) {
300300 }
301301
302302 /**
303- * @see Comparable::equals
304- *
305- * Two items are considered equal if they are of the same
306- * type and have the same value. The value does not include
307- * the id, so entities with the same value but different id
308- * are considered equal.
303+ * @see EntityDocument::equals
309304 *
310305 * @since 0.1
311306 *
312- * @param mixed $target
307+ * @param EntityDocument $entity
313308 *
314309 * @return bool
315310 */
316- public function equals ( $ target ) {
317- if ( $ this === $ target ) {
311+ public function equals ( EntityDocument $ entity ) {
312+ if ( $ this === $ entity ) {
318313 return true ;
319314 }
320315
321- return $ target instanceof self
322- && $ this ->fingerprint ->equals ( $ target ->fingerprint )
323- && $ this ->siteLinks ->equals ( $ target ->siteLinks )
324- && $ this ->statements ->equals ( $ target ->statements );
316+ return $ entity instanceof self
317+ && $ this ->fingerprint ->equals ( $ entity ->fingerprint )
318+ && $ this ->siteLinks ->equals ( $ entity ->siteLinks )
319+ && $ this ->statements ->equals ( $ entity ->statements );
325320 }
326321
327322}
Original file line number Diff line number Diff line change @@ -190,28 +190,23 @@ public static function newFromType( $dataTypeId ) {
190190 }
191191
192192 /**
193- * @see Comparable::equals
194- *
195- * Two properties are considered equal if they are of the same
196- * type and have the same value. The value does not include
197- * the id, so entities with the same value but different id
198- * are considered equal.
193+ * @see EntityDocument::equals
199194 *
200195 * @since 0.1
201196 *
202- * @param mixed $target
197+ * @param EntityDocument $entity
203198 *
204199 * @return bool
205200 */
206- public function equals ( $ target ) {
207- if ( $ this === $ target ) {
201+ public function equals ( EntityDocument $ entity ) {
202+ if ( $ this === $ entity ) {
208203 return true ;
209204 }
210205
211- return $ target instanceof self
212- && $ this ->dataTypeId === $ target ->dataTypeId
213- && $ this ->fingerprint ->equals ( $ target ->fingerprint )
214- && $ this ->statements ->equals ( $ target ->statements );
206+ return $ entity instanceof self
207+ && $ this ->dataTypeId === $ entity ->dataTypeId
208+ && $ this ->fingerprint ->equals ( $ entity ->fingerprint )
209+ && $ this ->statements ->equals ( $ entity ->statements );
215210 }
216211
217212 /**
You can’t perform that action at this time.
0 commit comments