Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* Added `ByPropertyIdGrouper`
* Added `BestStatementsFinder`

#### Deprecations

* Deprecated `ByPropertyIdArray` in favour of `ByPropertyIdGrouper`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ByPropertyIdArray has all this moving stuff, which ByPropertyIdGrouper does not have. Unfortunately that stuff is needed. If it was not, we'd just be able to kill it and stick with a sane ByPropertyIdArray.


## Version 1.0 (2014-09-02)

#### Breaking changes
Expand Down
1 change: 1 addition & 0 deletions src/ByPropertyIdArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* o3 (p2) ---> move to index 0 -/ o1 (p1)
*
* @since 0.2
* @deprecated since 1.1 - use ByPropertyIdGrouper instead
*
* @licence GNU GPL v2+
* @author H. Snater < mediawiki@snater.com >
Expand Down
10 changes: 5 additions & 5 deletions src/Claim/Claims.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Wikibase\DataModel\Claim;

use ArrayAccess;
use ArrayObject;
use Comparable;
use Hashable;
use InvalidArgumentException;
use Traversable;
use Wikibase\DataModel\ByPropertyIdArray;
use Wikibase\DataModel\ByPropertyIdGrouper;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\Snak\Snak;

Expand Down Expand Up @@ -317,14 +318,13 @@ public function getGuids() {
* @return Claims
*/
public function getClaimsForProperty( PropertyId $propertyId ) {
$claimsByProp = new ByPropertyIdArray( $this );
$claimsByProp->buildIndex();
$byPropertyIdGrouper = new ByPropertyIdGrouper( $this );

if ( !( in_array( $propertyId, $claimsByProp->getPropertyIds() ) ) ) {
if ( !$byPropertyIdGrouper->hasPropertyId( $propertyId ) ) {
return new self();
}

return new self( $claimsByProp->getByPropertyId( $propertyId ) );
return new self( $byPropertyIdGrouper->getByPropertyId( $propertyId ) );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is less readable than before

}

/**
Expand Down
19 changes: 5 additions & 14 deletions tests/unit/Claim/ClaimsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@

namespace Wikibase\Test;

use DataValues\StringValue;
use Diff\DiffOp\Diff\Diff;
use Diff\DiffOp\DiffOpAdd;
use Diff\DiffOp\DiffOpChange;
use Diff\DiffOp\DiffOpRemove;
use InvalidArgumentException;
use ReflectionClass;
use Wikibase\DataModel\ByPropertyIdArray;
use Wikibase\DataModel\Claim\Claim;
use Wikibase\DataModel\Claim\ClaimList;
use Wikibase\DataModel\Claim\Claims;
use Wikibase\DataModel\Statement\Statement;
use Wikibase\DataModel\Entity\PropertyId;
use Wikibase\DataModel\Reference;
use Wikibase\DataModel\ReferenceList;
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
use Wikibase\DataModel\Snak\PropertySomeValueSnak;
use Wikibase\DataModel\Snak\PropertyValueSnak;
use Wikibase\DataModel\Snak\Snak;
use Wikibase\DataModel\Snak\SnakList;
use Wikibase\DataModel\Statement\Statement;

/**
* @covers Wikibase\DataModel\Claim\Claims
Expand Down Expand Up @@ -66,10 +57,10 @@ public function testArrayObjectNotConstructedFromObject() {
$claim1 = $this->makeClaim( new PropertyNoValueSnak( 1 ) );
$claim2 = $this->makeClaim( new PropertyNoValueSnak( 2 ) );

$byPropertyIdArray = new ByPropertyIdArray();
$byPropertyIdArray->append( $claim1 );
$claimList = new ClaimList();
$claimList->addClaim( $claim1 );

$claims = new Claims( $byPropertyIdArray );
$claims = new Claims( $claimList );
// According to the documentation append() "cannot be called when the ArrayObject was
// constructed from an object." This test makes sure it was not constructed from an object.
$claims->append( $claim2 );
Expand Down