File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717 * Added ` getIterator ` method.
1818* Removed ` ReferenceList::removeDuplicates ` .
1919* ` ReferenceList::addReference ` now throws an ` InvalidArgumentException ` for negative indices.
20- * ` Entity ` no longer implements ` Comparable `
21- * Added ` EntityDocument::equals `
20+ * ` EntityDocument ` now implements ` Comparable ` .
2221
2322## Version 4.4.0 (2016-01-20)
2423
Original file line number Diff line number Diff line change 22
33namespace Wikibase \DataModel \Entity ;
44
5+ use Comparable ;
56use InvalidArgumentException ;
67
78/**
1415 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1516 * @author Bene* < benestar.wikimedia@gmail.com >
1617 */
17- interface EntityDocument {
18+ interface EntityDocument extends Comparable {
1819
1920 /**
2021 * Returns the id of the entity or null if it does not have one.
@@ -53,16 +54,4 @@ public function setId( $id );
5354 */
5455 public function isEmpty ();
5556
56- /**
57- * Two entities are considered equal if they are of the same
58- * type and have the same value. The value does not include
59- * the id, so entities with the same value but different id
60- * are considered equal.
61- *
62- * @param EntityDocument $entity
63- *
64- * @return bool
65- */
66- public function equals ( EntityDocument $ entity );
67-
6857}
Original file line number Diff line number Diff line change @@ -300,23 +300,28 @@ public function setStatements( StatementList $statements ) {
300300 }
301301
302302 /**
303- * @see EntityDocument::equals
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.
304309 *
305310 * @since 0.1
306311 *
307- * @param EntityDocument $entity
312+ * @param mixed $target
308313 *
309314 * @return bool
310315 */
311- public function equals ( EntityDocument $ entity ) {
312- if ( $ this === $ entity ) {
316+ public function equals ( $ target ) {
317+ if ( $ this === $ target ) {
313318 return true ;
314319 }
315320
316- return $ entity instanceof self
317- && $ this ->fingerprint ->equals ( $ entity ->fingerprint )
318- && $ this ->siteLinks ->equals ( $ entity ->siteLinks )
319- && $ this ->statements ->equals ( $ entity ->statements );
321+ return $ target instanceof self
322+ && $ this ->fingerprint ->equals ( $ target ->fingerprint )
323+ && $ this ->siteLinks ->equals ( $ target ->siteLinks )
324+ && $ this ->statements ->equals ( $ target ->statements );
320325 }
321326
322327}
Original file line number Diff line number Diff line change @@ -190,23 +190,28 @@ public static function newFromType( $dataTypeId ) {
190190 }
191191
192192 /**
193- * @see EntityDocument::equals
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.
194199 *
195200 * @since 0.1
196201 *
197- * @param EntityDocument $entity
202+ * @param mixed $target
198203 *
199204 * @return bool
200205 */
201- public function equals ( EntityDocument $ entity ) {
202- if ( $ this === $ entity ) {
206+ public function equals ( $ target ) {
207+ if ( $ this === $ target ) {
203208 return true ;
204209 }
205210
206- return $ entity instanceof self
207- && $ this ->dataTypeId === $ entity ->dataTypeId
208- && $ this ->fingerprint ->equals ( $ entity ->fingerprint )
209- && $ this ->statements ->equals ( $ entity ->statements );
211+ return $ target instanceof self
212+ && $ this ->dataTypeId === $ target ->dataTypeId
213+ && $ this ->fingerprint ->equals ( $ target ->fingerprint )
214+ && $ this ->statements ->equals ( $ target ->statements );
210215 }
211216
212217 /**
You can’t perform that action at this time.
0 commit comments