Skip to content

Commit 59f1440

Browse files
committed
Merge branch 'master' of github.com:wmde/WikibaseDataModel
2 parents 28993cb + c5c1d2d commit 59f1440

15 files changed

Lines changed: 19 additions & 46 deletions

Aliases.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ abstract class HashArray extends \Wikibase\DataModel\HashArray {}
6161
/**
6262
* @deprecated since 0.6, use the base class instead.
6363
*/
64-
interface MapHasher extends \Wikibase\DataModel\MapHasher {}
65-
66-
/**
67-
* @deprecated since 0.6, use the base class instead.
68-
*/
69-
class MapValueHasher extends \Wikibase\DataModel\MapValueHasher {}
64+
interface MapHasher extends DataModel\Internal\MapHasher {}
7065

7166
/**
7267
* @deprecated since 0.6, use the base class instead.

RELEASE-NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Other breaking changes:
4848
* `SiteLinkList::addNewSiteLink` no longer returns a `SiteLinkList` instance
4949
* Removed the global variable `evilDataValueMap`
5050
* Removed `ClaimAggregate` interface, which is thus no longer implemented by `Entity`
51+
* `HashableObjectStorage::getValueHash` no longer accepts a first optional parameter
52+
* `MapHasher` and `MapValueHasher` are now package private
5153

5254
#### Additions
5355

WikibaseDataModel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class_alias( 'Wikibase\DataModel\References', 'Wikibase\References' );
3232
class_alias( 'Wikibase\DataModel\ReferenceList', 'Wikibase\ReferenceList' );
3333
class_alias( 'Wikibase\DataModel\HashableObjectStorage', 'Wikibase\HashableObjectStorage' );
3434
class_alias( 'Wikibase\DataModel\HashArray', 'Wikibase\HashArray' );
35-
class_alias( 'Wikibase\DataModel\MapHasher', 'Wikibase\MapHasher' );
36-
class_alias( 'Wikibase\DataModel\MapValueHasher', 'Wikibase\MapValueHasher' );
35+
class_alias( 'Wikibase\DataModel\Internal\MapHasher', 'Wikibase\MapHasher' );
3736
class_alias( 'Wikibase\DataModel\ByPropertyIdArray', 'Wikibase\ByPropertyIdArray' );
3837
class_alias( 'Wikibase\DataModel\Claim\Claim', 'Wikibase\Claim' );
3938
class_alias( 'Wikibase\DataModel\Claim\ClaimListAccess', 'Wikibase\ClaimListAccess' );

src/Entity/EntityId.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ public function __toString() {
110110
* @return boolean
111111
*/
112112
public function equals( $target ) {
113-
return $target instanceof EntityId
114-
&& $target->getSerialization() === $this->serialization
115-
&& $target->getEntityType() === $this->entityType;
113+
return $target instanceof self
114+
&& $target->serialization === $this->serialization;
116115
}
117116

118117
/**

src/Entity/Item.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ public function addClaim( Claim $claim ) {
333333
throw new InvalidArgumentException( 'Can\'t add a Claim without a GUID.' );
334334
}
335335

336-
// TODO: ensure guid is valid for entity
337-
338336
$this->statements[] = $claim;
339337
}
340338

@@ -357,8 +355,6 @@ public function getClaims() {
357355
}
358356

359357
/**
360-
* TODO: change to take Claim[]
361-
*
362358
* @since 0.4
363359
*
364360
* @param Claims $claims

src/HashArray.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Hashable;
66
use InvalidArgumentException;
7+
use Wikibase\DataModel\Internal\MapValueHasher;
78

89
/**
910
* Generic array object with lookups based on hashes of the elements.
@@ -205,8 +206,6 @@ public function removeByElementHash( $elementHash ) {
205206
* @return boolean Indicates if the element was added or not.
206207
*/
207208
public function addElement( Hashable $element ) {
208-
// TODO: this duplicates logic of preSetElement
209-
// Probably best update setElement in GenericArrayObject to return boolean it got from preSetElement
210209
$append = $this->acceptDuplicates || !$this->hasElementHash( $element->getHash() );
211210

212211
if ( $append ) {
@@ -282,8 +281,6 @@ function( $value ) use ( $index ) {
282281
*
283282
* @since 0.1
284283
*
285-
* @internal param MapHasher $mapHasher
286-
*
287284
* @return string
288285
*/
289286
public function getHash() {

src/HashableObjectStorage.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Wikibase\DataModel;
44

55
use Hashable;
6+
use Wikibase\DataModel\Internal\MapValueHasher;
67

78
/**
89
* Object storage for Hashable objects.
@@ -58,25 +59,12 @@ public function removeDuplicates() {
5859
/**
5960
* The hash is purely valuer based. Order of the elements in the array is not held into account.
6061
*
61-
* Note: we cannot implement Hashable interface by having this be getHash since PHP 5.4
62-
* introduced a similarly named method in SplObjectStorage.
63-
*
6462
* @since 0.3
6563
*
66-
* @internal param MapHasher $mapHasher
67-
*
6864
* @return string
6965
*/
7066
public function getValueHash() {
71-
// We cannot have this as optional arg, because then we're no longer
72-
// implementing the Hashable interface properly according to PHP...
73-
$args = func_get_args();
74-
75-
/**
76-
* @var MapHasher $hasher
77-
*/
78-
$hasher = array_key_exists( 0, $args ) ? $args[0] : new MapValueHasher();
79-
67+
$hasher = new MapValueHasher();
8068
return $hasher->hash( $this );
8169
}
8270

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?php
22

3-
namespace Wikibase\DataModel;
3+
namespace Wikibase\DataModel\Internal;
44

55
use Traversable;
66

77
/**
88
* Interface for objects that can hash a map (ie associative array).
99
* Elements must implement Hashable.
1010
*
11-
* TODO: might want to make this internal to DataModel.
12-
*
1311
* @licence GNU GPL v2+
1412
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
1513
*/
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

3-
namespace Wikibase\DataModel;
3+
namespace Wikibase\DataModel\Internal;
44

55
use Hashable;
66
use InvalidArgumentException;
77
use Traversable;
8+
use Wikibase\DataModel\Internal\MapHasher;
89

910
/**
1011
* Generates hashes for associative arrays based on the values of their elements.

src/Reference.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ public function getHash() {
8383
* @return boolean
8484
*/
8585
public function equals( $mixed ) {
86-
return is_object( $mixed )
87-
&& $mixed instanceof Reference
88-
&& $this->getSnaks()->equals( $mixed->getSnaks() );
86+
return $mixed instanceof self
87+
&& $this->snaks->equals( $mixed->snaks );
8988
}
9089

9190
}

0 commit comments

Comments
 (0)