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.
@@ -54,15 +55,17 @@ public function setId( $id );
5455 public function isEmpty ();
5556
5657 /**
58+ * @see Comparable::equals
59+ *
5760 * Two entities are considered equal if they are of the same
5861 * type and have the same value. The value does not include
5962 * the id, so entities with the same value but different id
6063 * are considered equal.
6164 *
62- * @param EntityDocument $entity
65+ * @param mixed $target
6366 *
6467 * @return bool
6568 */
66- public function equals ( EntityDocument $ entity );
69+ public function equals ( $ target );
6770
6871}
Original file line number Diff line number Diff line change @@ -304,19 +304,19 @@ public function setStatements( StatementList $statements ) {
304304 *
305305 * @since 0.1
306306 *
307- * @param EntityDocument $entity
307+ * @param mixed $target
308308 *
309309 * @return bool
310310 */
311- public function equals ( EntityDocument $ entity ) {
312- if ( $ this === $ entity ) {
311+ public function equals ( $ target ) {
312+ if ( $ this === $ target ) {
313313 return true ;
314314 }
315315
316- return $ entity instanceof self
317- && $ this ->fingerprint ->equals ( $ entity ->fingerprint )
318- && $ this ->siteLinks ->equals ( $ entity ->siteLinks )
319- && $ this ->statements ->equals ( $ entity ->statements );
316+ return $ target instanceof self
317+ && $ this ->fingerprint ->equals ( $ target ->fingerprint )
318+ && $ this ->siteLinks ->equals ( $ target ->siteLinks )
319+ && $ this ->statements ->equals ( $ target ->statements );
320320 }
321321
322322}
Original file line number Diff line number Diff line change @@ -194,19 +194,19 @@ public static function newFromType( $dataTypeId ) {
194194 *
195195 * @since 0.1
196196 *
197- * @param EntityDocument $entity
197+ * @param mixed $target
198198 *
199199 * @return bool
200200 */
201- public function equals ( EntityDocument $ entity ) {
202- if ( $ this === $ entity ) {
201+ public function equals ( $ target ) {
202+ if ( $ this === $ target ) {
203203 return true ;
204204 }
205205
206- return $ entity instanceof self
207- && $ this ->dataTypeId === $ entity ->dataTypeId
208- && $ this ->fingerprint ->equals ( $ entity ->fingerprint )
209- && $ this ->statements ->equals ( $ entity ->statements );
206+ return $ target instanceof self
207+ && $ this ->dataTypeId === $ target ->dataTypeId
208+ && $ this ->fingerprint ->equals ( $ target ->fingerprint )
209+ && $ this ->statements ->equals ( $ target ->statements );
210210 }
211211
212212 /**
You can’t perform that action at this time.
0 commit comments