Skip to content

Commit 123bd51

Browse files
committed
Removed Claims::equals
1 parent 3e44a46 commit 123bd51

3 files changed

Lines changed: 2 additions & 84 deletions

File tree

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Removed `Claims::getClaimsForProperty` (you can use `StatementList::getWithPropertyId` instead)
1616
* Removed `Claims::getHashes`
1717
* Removed `Claims::getGuids`
18+
* Removed `Claims::equals` (and `Claims` no longer implements `Comparable`)
1819

1920
## Version 2.6.0 (2015-03-08)
2021

src/Claim/Claims.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @author Daniel Kinzler
2323
* @author H. Snater < mediawiki@snater.com >
2424
*/
25-
class Claims extends ArrayObject implements Hashable, Comparable {
25+
class Claims extends ArrayObject implements Hashable {
2626

2727
/**
2828
* @see GenericArrayObject::__construct
@@ -306,38 +306,4 @@ public function isEmpty() {
306306
return !$this->getIterator()->valid();
307307
}
308308

309-
/**
310-
* @see Comparable::equals
311-
*
312-
* @since 0.7.4
313-
*
314-
* @param mixed $target
315-
*
316-
* @return bool
317-
*/
318-
public function equals( $target ) {
319-
if ( $this === $target ) {
320-
return true;
321-
}
322-
323-
if ( !( $target instanceof self )
324-
|| $this->count() !== $target->count()
325-
) {
326-
return false;
327-
}
328-
329-
foreach ( $this as $claim ) {
330-
if ( !$target->hasExactClaim( $claim ) ) {
331-
return false;
332-
}
333-
}
334-
335-
return true;
336-
}
337-
338-
private function hasExactClaim( Claim $claim ) {
339-
return $this->hasClaim( $claim )
340-
&& $this->getClaimWithGuid( $claim->getGuid() )->equals( $claim );
341-
}
342-
343309
}

tests/unit/Claim/ClaimsTest.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -462,53 +462,4 @@ public function testIsEmpty() {
462462
$this->assertTrue( $claims->isEmpty() );
463463
}
464464

465-
public function testEmptyListEqualsEmptyList() {
466-
$list = new Claims( array() );
467-
$this->assertTrue( $list->equals( clone $list ) );
468-
}
469-
470-
public function testFilledListEqualsItself() {
471-
$list = new Claims( array(
472-
$this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P1' ) ) ),
473-
$this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P2' ) ) ),
474-
) );
475-
476-
$this->assertTrue( $list->equals( $list ) );
477-
$this->assertTrue( $list->equals( clone $list ) );
478-
}
479-
480-
public function testGivenNonClaimList_equalsReturnsFalse() {
481-
$list = new Claims( array() );
482-
483-
$this->assertFalse( $list->equals( null ) );
484-
$this->assertFalse( $list->equals( new \stdClass() ) );
485-
}
486-
487-
public function testGivenDifferentList_equalsReturnsFalse() {
488-
$list = new Claims( array(
489-
$this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P1' ) ) ),
490-
$this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P2' ) ) ),
491-
) );
492-
493-
$otherList = new Claims( array(
494-
$this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P3' ) ) ),
495-
$this->makeStatement( new PropertyNoValueSnak( new PropertyId( 'P4' ) ) ),
496-
) );
497-
498-
$this->assertFalse( $list->equals( $otherList ) );
499-
}
500-
501-
public function testGivenDifferentClaimWithSameGuid_equalsReturnsFalse() {
502-
$claim = new Claim( new PropertyNoValueSnak( 42 ) );
503-
$claim->setGuid( 'kittens' );
504-
505-
$newClaim = new Claim( new PropertyNoValueSnak( 1337 ) );
506-
$newClaim->setGuid( 'kittens' );
507-
508-
$list = new Claims( array( $claim ) );
509-
$newList = new Claims( array( $newClaim ) );
510-
511-
$this->assertFalse( $list->equals( $newList ) );
512-
}
513-
514465
}

0 commit comments

Comments
 (0)