Skip to content

Commit 40a5cbe

Browse files
committed
Merge pull request #151 from wmde/MapHasher
Make MapHasher package private
2 parents 7f98228 + 6e2ad29 commit 40a5cbe

11 files changed

Lines changed: 14 additions & 33 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/HashArray.php

Lines changed: 1 addition & 2 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.
@@ -280,8 +281,6 @@ function( $value ) use ( $index ) {
280281
*
281282
* @since 0.1
282283
*
283-
* @internal param MapHasher $mapHasher
284-
*
285284
* @return string
286285
*/
287286
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/Snak/SnakList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Wikibase\DataModel\Snak;
44

55
use Wikibase\DataModel\HashArray;
6-
use Wikibase\DataModel\MapValueHasher;
6+
use Wikibase\DataModel\Internal\MapValueHasher;
77

88
/**
99
* Implementation of the Snaks interface.

tests/component/AutoloadingAliasesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ function( $className ) {
3232
'Wikibase\HashableObjectStorage',
3333
'Wikibase\HashArray',
3434
'Wikibase\MapHasher',
35-
'Wikibase\MapValueHasher',
3635
'Wikibase\ByPropertyIdArray',
3736
'Wikibase\Claim',
3837
'Wikibase\ClaimListAccess',

tests/unit/MapValueHasherTest.php renamed to tests/unit/Internal/MapValueHasherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Wikibase\Test;
44

55
use Wikibase\DataModel\Entity\PropertyId;
6-
use Wikibase\DataModel\MapValueHasher;
6+
use Wikibase\DataModel\Internal\MapValueHasher;
77
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
88

99
/**
10-
* @covers Wikibase\DataModel\MapValueHasher
10+
* @covers Wikibase\DataModel\Internal\MapValueHasher
1111
*
1212
* @group Wikibase
1313
* @group WikibaseDataModel

0 commit comments

Comments
 (0)