Skip to content

Commit 9435e22

Browse files
thiemowmdeJeroenDeDauw
authored andcommitted
Remove Snaks interface
1 parent bf6e41f commit 9435e22

8 files changed

Lines changed: 19 additions & 103 deletions

File tree

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Phasing out of `Claims`:
3232

3333
Other breaking changes:
3434

35+
* Removed `Snaks` interface, use `SnakList` instead
3536
* Removed previously deprecated `Entity::getAllSnaks`, use `StatementList::getAllSnaks` instead
3637
* Removed previously deprecated `EntityId::getPrefixedId`, use `EntityId::getSerialization` instead
3738
* `Reference` and `ReferenceList`s no longer can not be instantiated with `null`

src/Reference.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use InvalidArgumentException;
66
use Wikibase\DataModel\Snak\Snak;
77
use Wikibase\DataModel\Snak\SnakList;
8-
use Wikibase\DataModel\Snak\Snaks;
98

109
/**
1110
* Object that represents a single Wikibase reference.
@@ -19,23 +18,23 @@
1918
class Reference implements \Hashable, \Comparable, \Immutable, \Countable {
2019

2120
/**
22-
* @var Snaks
21+
* @var SnakList
2322
*/
2423
private $snaks;
2524

2625
/**
2726
* An array of Snak objects is only supported since version 1.1.
2827
*
29-
* @param Snak[]|Snaks $snaks
28+
* @param Snak[]|SnakList $snaks
3029
* @throws InvalidArgumentException
3130
*/
3231
public function __construct( $snaks = array() ) {
3332
if ( is_array( $snaks ) ) {
3433
$snaks = new SnakList( $snaks );
3534
}
3635

37-
if ( !( $snaks instanceof Snaks ) ) {
38-
throw new InvalidArgumentException( '$snaks must be an array or an instance of Snaks' );
36+
if ( !( $snaks instanceof SnakList ) ) {
37+
throw new InvalidArgumentException( '$snaks must be an array or an instance of SnakList' );
3938
}
4039

4140
$this->snaks = $snaks;
@@ -47,7 +46,7 @@ public function __construct( $snaks = array() ) {
4746
*
4847
* @since 0.1
4948
*
50-
* @return Snaks
49+
* @return SnakList
5150
*/
5251
public function getSnaks() {
5352
return $this->snaks;
@@ -70,7 +69,6 @@ public function count() {
7069
* @return bool
7170
*/
7271
public function isEmpty() {
73-
// FIXME: Not all implementations of Snaks are guaranteed to have an isEmpty method.
7472
return $this->snaks->isEmpty();
7573
}
7674

src/Snak/SnakList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
use Wikibase\DataModel\Internal\MapValueHasher;
77

88
/**
9-
* Implementation of the Snaks interface.
10-
* @see Snaks
9+
* List of Snak objects.
10+
* Indexes the snaks by hash and ensures no more the one snak with the same hash are in the list.
1111
*
1212
* @since 0.1
1313
*
1414
* @licence GNU GPL v2+
1515
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
1616
* @author Adam Shorland
1717
*/
18-
class SnakList extends HashArray implements Snaks {
18+
class SnakList extends HashArray {
1919

2020
/**
2121
* @see GenericArrayObject::getObjectType

src/Snak/Snaks.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/Statement/Statement.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Wikibase\DataModel\ReferenceList;
1212
use Wikibase\DataModel\Snak\Snak;
1313
use Wikibase\DataModel\Snak\SnakList;
14-
use Wikibase\DataModel\Snak\Snaks;
1514

1615
/**
1716
* Class representing a Wikibase statement.
@@ -47,7 +46,7 @@ class Statement implements Hashable, Comparable, PropertyIdProvider {
4746
/**
4847
* The property value snaks making up the qualifiers for this statement.
4948
*
50-
* @var Snaks
49+
* @var SnakList
5150
*/
5251
private $qualifiers;
5352

@@ -65,13 +64,13 @@ class Statement implements Hashable, Comparable, PropertyIdProvider {
6564
* @since 2.0
6665
*
6766
* @param Snak $mainSnak
68-
* @param Snaks|null $qualifiers
67+
* @param SnakList|null $qualifiers
6968
* @param ReferenceList|null $references
7069
* @param string|null $guid
7170
*/
7271
public function __construct(
7372
Snak $mainSnak,
74-
Snaks $qualifiers = null,
73+
SnakList $qualifiers = null,
7574
ReferenceList $references = null,
7675
$guid = null
7776
) {
@@ -136,7 +135,7 @@ public function setMainSnak( Snak $mainSnak ) {
136135
*
137136
* @since 0.1
138137
*
139-
* @return Snaks
138+
* @return SnakList
140139
*/
141140
public function getQualifiers() {
142141
return $this->qualifiers;
@@ -147,9 +146,9 @@ public function getQualifiers() {
147146
*
148147
* @since 0.1
149148
*
150-
* @param Snaks $propertySnaks
149+
* @param SnakList $propertySnaks
151150
*/
152-
public function setQualifiers( Snaks $propertySnaks ) {
151+
public function setQualifiers( SnakList $propertySnaks ) {
153152
$this->qualifiers = $propertySnaks;
154153
}
155154

src/Statement/StatementList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Wikibase\DataModel\ReferenceList;
1414
use Wikibase\DataModel\Snak\Snak;
1515
use Wikibase\DataModel\Snak\SnakList;
16-
use Wikibase\DataModel\Snak\Snaks;
1716

1817
/**
1918
* Ordered and non-unique collection of Statement objects.
@@ -92,7 +91,7 @@ public function addStatement( Statement $statement ) {
9291

9392
/**
9493
* @param Snak $mainSnak
95-
* @param Snak[]|Snaks|null $qualifiers
94+
* @param Snak[]|SnakList|null $qualifiers
9695
* @param Reference[]|ReferenceList|null $references
9796
* @param string|null $guid
9897
*/

tests/unit/ReferenceTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Wikibase\DataModel\Snak\PropertySomeValueSnak;
1111
use Wikibase\DataModel\Snak\PropertyValueSnak;
1212
use Wikibase\DataModel\Snak\SnakList;
13-
use Wikibase\DataModel\Snak\Snaks;
1413

1514
/**
1615
* @covers Wikibase\DataModel\Reference
@@ -73,9 +72,8 @@ public function instanceProvider() {
7372

7473
/**
7574
* @dataProvider snakListProvider
76-
* @param Snaks $snaks
7775
*/
78-
public function testConstructor( Snaks $snaks ) {
76+
public function testConstructor( SnakList $snaks ) {
7977
$omnomnomReference = new Reference( $snaks );
8078

8179
$this->assertInstanceOf( 'Wikibase\DataModel\Reference', $omnomnomReference );
@@ -111,7 +109,7 @@ public function testGetHashIsTheSameForInstanceWithSameValue( Reference $referen
111109
public function testGetSnaks( Reference $reference ) {
112110
$snaks = $reference->getSnaks();
113111

114-
$this->assertInstanceOf( 'Wikibase\DataModel\Snak\Snaks', $snaks );
112+
$this->assertInstanceOf( 'Wikibase\DataModel\Snak\SnakList', $snaks );
115113
}
116114

117115
/**

tests/unit/Statement/StatementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testMinimalConstructor() {
3838
*/
3939
public function testConstructorWithValidArguments(
4040
Snak $mainSnak,
41-
Snaks $qualifiers = null,
41+
SnakList $qualifiers = null,
4242
ReferenceList $references = null,
4343
$guid
4444
) {

0 commit comments

Comments
 (0)