Skip to content

Commit 5cacbff

Browse files
committed
Merge pull request #491 from wmde/getByRank
Rename getWithRank to getByRank
2 parents a02da97 + 0d658f2 commit 5cacbff

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

RELEASE-NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Phasing out of `Claims`:
1818

1919
* `Claims::addClaim` no longer supports setting an index
2020
* Removed `Claims::getBestClaims`, use `StatementList::getBestStatements` instead
21-
* Removed `Claims::getByRank` and `Claims::getByRanks`, use `StatementList::getWithRank` instead
21+
* Removed `Claims::getByRank` and `Claims::getByRanks`, use `StatementList::getByRank` instead
2222
* Removed `Claims::getMainSnaks`, use `StatementList::getMainSnaks` instead
2323
* Removed `Claims::getClaimsForProperty`, use `StatementList::getWithPropertyId` instead
2424
* Removed `Claims::getHashes`
@@ -37,6 +37,7 @@ Other breaking changes:
3737
* Removed previously deprecated `EntityId::getPrefixedId`, use `EntityId::getSerialization` instead
3838
* Removed previously deprecated `Property::newEmpty`, use `Property::newFromType` or `new Property()` instead
3939
* Renamed `StatementList::getWithPropertyId` to `StatementList::getByPropertyId`
40+
* Renamed `StatementList::getWithRank` to `StatementList::getByRank`
4041
* `Reference` and `ReferenceList`s no longer can not be instantiated with `null`
4142
* Added `setId` method to `EntityDocument`
4243

src/Statement/StatementList.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ public function getByPropertyId( PropertyId $id ) {
159159
}
160160

161161
/**
162-
* @since 2.4
162+
* @since 3.0
163163
*
164164
* @param int|int[] $acceptableRanks
165165
*
166166
* @return self
167167
*/
168-
public function getWithRank( $acceptableRanks ) {
168+
public function getByRank( $acceptableRanks ) {
169169
$acceptableRanks = array_flip( (array)$acceptableRanks );
170170
$statementList = new self();
171171

@@ -188,13 +188,13 @@ public function getWithRank( $acceptableRanks ) {
188188
* @return self
189189
*/
190190
public function getBestStatements() {
191-
$statements = $this->getWithRank( Statement::RANK_PREFERRED );
191+
$statements = $this->getByRank( Statement::RANK_PREFERRED );
192192

193193
if ( !$statements->isEmpty() ) {
194194
return $statements;
195195
}
196196

197-
return $this->getWithRank( Statement::RANK_NORMAL );
197+
return $this->getByRank( Statement::RANK_NORMAL );
198198
}
199199

200200
/**

tests/unit/Statement/StatementListTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,12 @@ public function testGivenKnownPropertyId_getByPropertyIdReturnsListWithOnlyMatch
530530
);
531531
}
532532

533-
public function testGivenInvalidRank_getWithRankReturnsEmptyList() {
533+
public function testGivenInvalidRank_getByRankReturnsEmptyList() {
534534
$list = new StatementList();
535-
$this->assertEquals( new StatementList(), $list->getWithRank( 42 ) );
535+
$this->assertEquals( new StatementList(), $list->getByRank( 42 ) );
536536
}
537537

538-
public function testGivenValidRank_getWithRankReturnsOnlyMatchingStatements() {
538+
public function testGivenValidRank_getByRankReturnsOnlyMatchingStatements() {
539539
$statement = new Statement( new PropertyNoValueSnak( 42 ) );
540540
$statement->setRank( Statement::RANK_PREFERRED );
541541

@@ -549,12 +549,12 @@ public function testGivenValidRank_getWithRankReturnsOnlyMatchingStatements() {
549549

550550
$this->assertEquals(
551551
new StatementList( $statement ),
552-
$list->getWithRank( Statement::RANK_PREFERRED )
552+
$list->getByRank( Statement::RANK_PREFERRED )
553553
);
554554

555555
$this->assertEquals(
556556
new StatementList( $secondStatement, $thirdStatement ),
557-
$list->getWithRank( array( Statement::RANK_NORMAL, Statement::RANK_DEPRECATED ) )
557+
$list->getByRank( array( Statement::RANK_NORMAL, Statement::RANK_DEPRECATED ) )
558558
);
559559
}
560560

0 commit comments

Comments
 (0)